Take a look at this gem: https://github.com/peleteiro/ruby-duration
—it will convert an arbitrary duration (like 1 month, 2 weeks, etc.) into 
seconds which can be stored in the DB. It is very similar to what Raj is 
recommending, just a little more formal. Either way you can avoid eval'ing 
code, and your calculation can be a lot more flexible.

On Friday, September 20, 2013 12:30:16 AM UTC-7, 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+unsubscr...@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/bd968e41-7f42-4ca0-91ba-a608b4a75955%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to