Skip to content

Instantly share code, notes, and snippets.

@bhaskarkotu
Created April 12, 2014 07:38
Show Gist options
  • Save bhaskarkotu/10523312 to your computer and use it in GitHub Desktop.
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.
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
@bhaskarkotu
Copy link
Author

link to debug from rails console......https://github.com/ryanb/cancan/wiki/Debugging-Abilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment