Convert to method call?

Hi all,

I would like to store a method call in a database, yet once saved I
don’t know how to convert it from a string back to a method call.

example:

distance_of_time_in_words(order.created_at, order.created_at +
order.due_date)

The value of order.due_date “10.weeks”, but could be “20.days”,
“100.months”, etc.

Just wondering if there’s a way to convert a
string “10.weeks”
to a method
10.weeks
?

Thanks for your help!

Dave

found it. “the google” said:

I split the 10 and weeks into two separate columns, due_in and due_from
(couldn’t thing of what to call em).

This seems to work just fine.

order.due_in.send(order.due_from.to_sym)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs