I am trying to overwrite the getter method for the ActiveRecord model. I have a name attribute in the Category model, and I would like to do something like this:
def name name_trans || name end
If the name_trans attribute name_trans not nil, then return it, otherwise return the name attribute. How should I do it?
Then it should usually be called as follows:
@category.name
ruby ruby-on-rails rails-activerecord getter-setter
Γyvind Hauge Feb 17 '14 at 17:06 2014-02-17 17:06
source share