I set a record's timestamp attribute (datetime
type) to 0
. I saved it (or not). I tried to set it to 0
again.
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
I got:
NoMethodError: undefined method `change' for 0:Fixnum
This happened even after restarting rails and reloading the record from the database (local sqlite3). Help!
Edit: The rails console stack trace is more illuminating than the one I get from the server:
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>'