If you really feel you need to do this then you can store "1.month" as
a string and use eval
1.9.3p194 :007 > delta = "1.month"
=> "1.month"
1.9.3p194 :008 > Time.now
=> 2013-09-22 08:52:13 +0100
1.9.3p194 :009 > Time.now + eval( delta )
=> 2013-10-22 08:52:23 +0100
However if you do this be /very/ careful about what can get into the
database as arbitrary code can be executed using eval and conceivably
your machine could be hacked. I DO NOT recommend that you do this.
If your requirement is for a delta with values such as 1 month 3 weeks
and so on, then I suggest having two fields, one for the quantity and
an enumerated value for the period (month, week and so on). Then work
it out in code. Less efficient but /much/ safer.
Colin
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to
rubyonra...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/rubyonrails-talk/a19f9925-f725-4cd5-9dfd-6c8c4b897bd6%40googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.