0
votes

Suppose we have an ActiveRecord model Group which has a property (and column in database) called name (it is actually not visible by default):

class Group < ActiveRecord::Base
  include App::CustomModule
end

Also there is a custom module CustomModule included into a Group model, which has a method called name:

module App
  module CustomModule
    def name
      'module name'
    end
  end
end

As a result, when referencing to a name inside of a Group model instance I get a value from a CustomModule's name method (the same is for self.name):

> Group.find(1).name
=> "module name"

How can I get a value for original name property of Group model instance (not module method value) without changing the names of both class property and module method?

rails (4.0.4) activerecord (4.0.4)

1

1 Answers

1
votes

This should do the trick:

group.read_attribute(:name)