Okay, so I need something like this:
time_span = "1.month"
date = DateTime.now
date = date + send("#{time_span}")
where time_span is actually stored on the database, but that doesn't seem to work.. Here's some console action:
$ rails c
>> time_span = 1.month
=> 1 month
>> date = DateTime.now + time_span
=> Fri, 27 Aug 2010 20:51:18 -0500
>> time_span.class
=> Fixnum
>> time_span = '1.month'
=> "1.month"
>> date = DateTime.now + time_span
TypeError: expected numeric
ruby/1.8/date.rb:1236:in `plus_without_duration'
date/calculations.rb:87:in `+'
from (irb):5
The idea is that I need to store 1.month as a string in the database because storing 1.month as a fixnum only stores the total number of seconds in that particular month, but I want it to be more dynamic based on the current month. I know send
in this case isn't being used as it's documentation suggests, but I have seen it used in this manner.