ruby - Understanding CanCan initialize method -
i'm having hard time understanding how cancan works. have following model
class ability include cancan::ability def initialize(user) if user && user.email == "jason@gmail.com" can :access, :rails_admin # allow admin users access rails admin can :dashboard # allow access dashboard end end end
when comes rails_admin file in initializers
folder
railsadmin.config |config| config.authorize_with :cancan config.main_app_name = ['pr', 'admin'] config.current_user_method { } # auto-generated end
i want have 1 user access admins dashboard email "jason@gmail.com", how cancan know signed in @ time? rely on helper method i'm missing?
cancan uses current_ability
method supply ability, and in uses current_user
. know @ least devise has method, other auth frameworks must commonly supply too, not sure.
Comments
Post a Comment