我将记录的时间戳属性(datetime
类型)设置为0
. 我保存了它(或没有保存)。我试图重新设置它0
。
a = MyModel.last # => #<MyModel id:...
a.updated_at # => Tue, 12 Mar 2013 01:36:17 UTC +00:00
a.updated_at = 0 # => 0
a.updated_at = 0
我有:
NoMethodError: undefined method `change' for 0:Fixnum
即使在重新启动 rails 并从数据库(本地 sqlite3)重新加载记录之后也会发生这种情况。帮助!
编辑:rails 控制台堆栈跟踪比我从服务器获得的更有启发性:
NoMethodError: undefined method `change' for 0:Fixnum
from /Users/nolan/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/attribute_methods/time_zone_conversion.rb:69:in `round_usec'
from /Users/nolan/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/attribute_methods/time_zone_conversion.rb:46:in `fields_updasqliteted_at='
from (irb):23
from /Users/nolan/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/nolan/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/nolan/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:8:in `require'
from script/rails:8:in `<main>'