ruby - Rails NoMethodError when calling method on parent -
playing around single table inheritance , hstore in rails 4 getting error when trying call method in parent:
# models/item.rb class item < activerecord::base def getter_setter_for(key) define_method(key) properties && properties[key] end define_method("#{key}=") |value| self.properties = (properties || {}).merge(key => value) end end end # models/disk_item.rb class diskitem < item %w[filename path].each |key| getter_setter_for(key) ## <== error calling method end end
error:
exception encountered: #<nomethoderror: undefined method `getter_setter_for' #<class:0x007f8c739a5ae0>>
what obvious thing have overlooked?
getter_setter_for(key) instance method. getting called @ class level. called during diskitem class load on class scope.
Comments
Post a Comment