attr_accessor
does not work on the following code. The error says \"undefined method \'things\' for Parent:Class (NoMethodError)
\":
Just some clarification: class variables won't be accessible using attr_accessor
. It's all about instance variables:
class SomeClass
class << self
attr_accessor :things
end
@things = []
end
because in Ruby, class is an instance of the class "Class" (God, I love to say that) and attr_accessor
sets accessor methods for instance variables.