【发布时间】:2012-10-12 20:09:43
【问题描述】:
我正在尝试使用 mysql2 适配器和 ActiveRecord 从 MySQL 数据库中的各个字段中删除空格和回车:
红宝石 1.9.3p194
ActiveRecord 3.2.8
MySQL 5.5.28
foo = People.find(1)
foo.name => "\rJohn Jones"
foo.name.lstrip! => "John Jones"
foo.name => "John Jones"
foo.changes => {} #no changes detected to foo.name???
foo.save => true # but does nothing to database.
如果我这样做:
foo.name = "John Jones"
foo.save => true
People.find(1).name => "John Jones" # this works and saves to database
我已经到处搜索了...有什么建议吗?
【问题讨论】:
标签: mysql ruby activerecord