Fetch a Rails ActiveRecord 'datetime' attribute as a DateTime object?

You can always create a method to override the attribute, as follows: class YourModel .... def ended_on self'ended_on'. To_datetime # if you need date object use to_date instead end .... end Hopefully that helps.

Thanks, this seems to do the job. The code I actually used was self'ended_on' && self'ended_on'. To_datetime so it won't have any trouble with nil values.

I'm still a little worried about 2040, but I guess there will be many new versions of Rails to upgrade to before then anyway. – Tobias Cohen May 18 '10 at 1:06.

You can convert the Time Object very easy with Time::to_date or Time::to_datetime. For more information on this: api.rubyonrails.org/classes/ActiveSuppor... so you should change your code like this: myevent. Ended_on.

To_date # or myevent. Ended_on. To_datetime.

Attributes_cachename || @attributes_cache. Column = @columns_hash. If name == 'id' && self.class.

Value = @attributes. @attributes_cachename = column.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions