ActiveRecord seems to define instance methods differently than attr_accessor.
attr_accessor doesn't seem to define a super method for my new defined attribute:
class SomeClass
attr_accessor :some_attribute
def some_attribute
super
end
end
>> some_class = SomeClass.new
>> some_class.some_attribute
NoMethodError: super: no superclass method `some_attribute' for..
Whereas ActiveRecord definitely defines a super method:
class SomeClass < ActiveRecord::Base
# some_attribute is now a column in our database
def some_attribute
super
end
end
>> some_class = SomeClass.new
>> some_class.some_attribute
nil
Where is the difference between both? Is there a way to make attr_accessor define a super method?
EDIT:
I still don't know how ActiveRecord defines it's methods, but I know how attr_accessor does it. Instead of super
I can use @some_attribute
since it stores the values in global variables of the same name: https://stackoverflow.com/a/4371458/586000