Displaying 1 result from an estimated 1 matches for "value_of_attribute".
2006 Mar 19
3
How can I access an attribute via a symbol?
In my model I''d like to write a method that accesses the attributes by
name. A very simple implementation would be
class MyModel < ActiveRecord::Base
def get_value(attribute)
return value_of_attribute
end
end
Then I can call it with m.get_value(:name) to get the value of the
name column in the db. I''m not sure what to put in for
''value_of_attribute'' though. How do I do that?
Pat