Friday, September 20, 2013

[Rails] Re: Retrieve duration (in string format) from database and convert to Ruby syntax for calculation

I don't think this is good idea. 1.month.to_i will return in seconds as 2592000. you can store this and while fetching you can use it as it is
Time.now + 2592000

On Friday, 20 September 2013 03:30:16 UTC-4, Fai Wong wrote:
If I store 1.month as a string in the database, how do I convert "1.month" into 1.month?

This way I can use the "1.month" value stored in database to perform the following calculation.

Time.now + 1.month 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a48f71fa-1f31-4037-94a4-c876bbc2630a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate