I have User model created with Devise, with type:string attribute and a AdminUser model (AdminUser < User
).
In application controller I defined the :require_admin method:
def require_admin
unless current_user == AdminUser
flash[:error] = "You are not an admin"
redirect_to store_index_path
end
end
On products controller I set
before_action :require_admin, except: :show
Now I create an AdminUser via console successfully (with AdminUser id) and when I log in the app, I still can not use those actions (create, edit etc.).
Any ideas?