attr_accessor
does not work on the following code. The error says "undefined method 'things' for Parent:Class (NoMethodError)
":
class Parent
@@things = []
attr_accessor :things
end
Parent.things << :car
p Parent.things
However the following code works
class Parent
@@things = []
def self.things
@@things
end
def things
@@things
end
end
Parent.things << :car
p Parent.things