I have added some constants to a model say MyModel.rb
as shown below.
MY_CONST = {
:foo =>"Some Name for Foo",
:bar =>"Some Name for Bar"
}
Also I have saved string foo
as the column value in a table record.
@m = MyModel.find(1)
@m.column_name #=> foo
Now in my view I need to show "Some Name for Foo" as the output for @m.column_name
instead of foo
I tried MyModel::MY_CONST[:foo]
and it prints "Some Name for Foo"
as the output. But I don't know how to pass @m.column_name
to MyModel::MY_CONST[....]
dynamically.