# Convert to method call?

**URL:** <https://www.ruby-forum.com/t/convert-to-method-call/87680>\
**Category:** Rails\
**Created:** [March 5, 2007, 3:52am UTC](https://www.ruby-forum.com/t/convert-to-method-call/87680 "2007-03-05T03:52:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [March 5, 2007, 3:52am UTC](https://www.ruby-forum.com/t/convert-to-method-call/87680/1 "2007-03-05T03:52:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [March 5, 2007, 4:18am UTC](https://www.ruby-forum.com/t/convert-to-method-call/87680/2 "2007-03-05T04:18:07Z")

</div>

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)
