我正在尝试使用 mysql2 适配器和 ActiveRecord 从 MySQL 数据库中的各个字段中删除空格和回车:
Ruby 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
我已经到处搜索了...有什么建议吗?