attr_accessor breaks 2 of my methods in Rails
I have a User model. One of its attributes is a string called :access
which can be either nil, "admin", or "active".
Now inside the User model I have the following methods:
def admin?
self.access == "admin"
end
def active?
self.access == "active"
end
They work fine. But if I add attr_accessor :access to the model something
breaks. My admin? and active? methods no longer work. When I go into rails
console and get a User out of the database I can see that user =
User.find(7) shows access is set to "admin". But if I type user.access it
returns nil. user.admin? returns false.
No comments:
Post a Comment