Skip to content

Instantly share code, notes, and snippets.

@vastus
Created March 11, 2014 19:04
Show Gist options
  • Save vastus/9492705 to your computer and use it in GitHub Desktop.
Save vastus/9492705 to your computer and use it in GitHub Desktop.
How to access subclasses instance variables in superclass
class Model
def self.all
puts self.table
end
class << self
attr_reader :table
end
end
class User < Model
@table = 'users'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment