rails3 authlogic admin roles
I have authlogic working fine but now have the need to let administrator users come in and have different access.
So I created a migration adding administrator
column to the Users
table as string. However, I just can not seem to get the val开发者_C百科ue of it out!!
see below my index action:
print "\n administrator" + User.find(current_user.id).administrator.to_s
the above line never prints anything when I know that this user HAS administrator
string set to true
in the db.
Below is the User model
class User < ActiveRecord::Base
acts_as_authentic {|config|
config.validates_uniqueness_of_email_field_options :scope => :id
}
belongs_to :another_class
end
what am I doing wrong here? All I want to do is get the administrator column value out. In the logs I can see the select users.* from users where id = 2
query being run!
is there another best way to manage admin roles with authlogic??
You're likely better off using cancan for managing roles and permissions. It can be used in combination with authlogic.
If you are going to just add a flag "administrator" field to the user record, it should work as long as your rules are simple, but would be better as a boolean rather than a string.
You say you have an "administrator" column of strings in your database and you're looking for a value of true. Maybe you wanted a Boolean column?
精彩评论