activerecord model constantize question

I have a variable called column with the value of "bla" (column =
"bla")

I have a model call Location where method bla is defined (amongst many
other methods). What I would like to to is to call the method in
Location defined in the variable column.

I tried:

Location.column.constantize

but that gave me an error NoMethod.

I am sure there is a very simple way in Ruby as always :slight_smile:

who can help me?

thanks

bitterbal wrote:

I have a variable called column with the value of "bla" (column =
"bla")

I have a model call Location where method bla is defined (amongst many
other methods). What I would like to to is to call the method in
Location defined in the variable column.

you can use Ruby's send[1] method on the location object with the column
name. Like so:

column = "bla"
my_location = Location.find(1)
my_location.send(column) # calls mylocation.bla

[1] http://www.ruby-doc.org/core/classes/Object.html#M000334

Thanks ! I was already reading through the API docs did not find it
yet