Reputation: 6259
I have a simple model:
class Card < ActiveRecord::Base
enum person: {old: 1, young: 2}
end
But when I log into my console and try to do:
Card.person
I get:
NoMethodError: undefined method `person'
What do I wrong? And how can i get the enum hash? Thanks
Upvotes: 1
Views: 90
Reputation: 35483
Rails says: In rare circumstances you might need to access the mapping directly. The mappings are exposed through a class method with the pluralized attribute name.
So for you:
Card.people
Upvotes: 2