Model Commands

I’d like to do something like this in my RoR code:

name = “james”
box = Box.find(1)
box_name = box.name

Where “james” is an existing column in table Box. I try to do this but
RoR tells me “undefined method `name’ for #Box:0x333a81c”. Is it
possible to get around this? Basically what I have is a list of strings
that I need to use as column commands.

Thanks in advance for any help.

On Feb 29, 2008, at 10:01 PM, Mariko C. wrote:

strings
that I need to use as column commands.

Thanks in advance for any help.

Posted via http://www.ruby-forum.com/.

You want to send a message with to the method “james”. What you are
doing is sending a message to the method “name”.

What you want to do is:

=== code ===

name = “james”
box = Box.find(1)
box_name = box.send(name)

=== code ===

I don’t know what you want to acomplish, but this is how it works.

Greetings
Florian G.

That works perfectly. Many thanks for your quick response!