Closed dchersey closed 10 years ago
If you look at model.rb
, you'll see this code:
# Set created_at and updated_at fields
def set_auto_date_field(field_name)
method = "#{field_name}="
self.send(method, Time.now) if self.respond_to?(method)
end
This relies on you having a field named created_at or updated_at. If you create them as type :date
you may not be getting the time component. Otherwise, I don't see how you are losing that. Can you create a failing spec?
Never mind … I just realized that my brain was conflating ruby (with separate Date, Time and DateTime classes) and rubymotion (with only NSDate which combines all 3).
That's what I get for working on 2 projects at once :)
This issue first surfaced when I was using formotion to show the created_at and it defaults to only showing/picking Date. I then looked at the model declaration, saw type :date and proceeded to assume that's all I had.
Thanks for your quick response!
On Oct 16, 2013, at 12:52 PM, "s.ross" notifications@github.com wrote:
If you look at model.rb, you'll see this code:
# Set created_at and updated_at fields def set_auto_date_field(field_name) method = "#{field_name}=" self.send(method, Time.now) if self.respond_to?(method) end
This relies on you having a field named created_at or updated_at. If you create them as type :date you may not be getting the time component. Otherwise, I don't see how you are losing that. Can you create a failing spec?
— Reply to this email directly or view it on GitHub.
No problem. Enjoy using MM!
The documentation states that the created_at & updated_at fields must be of type date. As such, it only captures the day of the create or update. This is odd, as usually you want to use this more precisely.
I also don't see a separate type for time or datetime ... so I guess I can just store time as an integer using Time.to_i .... am I missing something?