I know there is a current_user method for devise, but how do you check if the user is admin? (I’ve got a user flagged as admin).
I have a admin menu that I’d like to enable / disable when admin is logged in.
Thanks,
Joe
I know there is a current_user method for devise, but how do you check if the user is admin? (I’ve got a user flagged as admin).
I have a admin menu that I’d like to enable / disable when admin is logged in.
Thanks,
Joe
Do you mean that you have a column in users table named admin which is true or false? if so then just test current_user.admin
Colin
Is it a boolean column? We wind up setting @user = current_user, and then checking
if @user.admin
#current_user.admin should work just as well if you don’t need to hang on to the actual signed in user.
…
end
Otherwise,
@user.<column_name> == “admin” #(or whatever you use)
cheers,
Bill
Yes, lol. That easy. I’ll try it.
Thanks, that worked !