Created
April 12, 2014 07:38
-
-
Save bhaskarkotu/10523312 to your computer and use it in GitHub Desktop.
Getting 'You are not authorized to access this page.' error even for administrator role.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user ||= User.new # guest user (not logged in) | |
if user.has_role? 'Administrator' | |
can :manage, :all | |
elsif user.has_role? 'Project manager' | |
can :read, Project, :id => user.projects.pluck(:id) | |
can :manage, Budget | |
can :assignusertoproject, Project | |
can :updateuserprojectcontract, Project | |
can :destroyprojectcontract, Project, :id => user.projects.pluck(:id) | |
#can :read, Project, :id => Project.with_role('Project Manager', user).pluck(:id) | |
end | |
budgets_controller.rb | |
--------------------------------- | |
load_and_authorize_resource :budgets, | |
:through => :projects, :class => 'Project', | |
:find_by => :project_id, | |
:id_param => :project_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
link to debug from rails console......https://github.com/ryanb/cancan/wiki/Debugging-Abilities