Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with custom actions #64

Closed
hsgrott opened this issue May 19, 2014 · 1 comment
Closed

Problem with custom actions #64

hsgrott opened this issue May 19, 2014 · 1 comment
Assignees

Comments

@hsgrott
Copy link

hsgrott commented May 19, 2014

Suppose I have the following:

# routes.rb

resources :plans do
  collection do
    get 'requested'
    get 'pending'
  end
end

# PlansController

load_and_authorize_resource 

def requested
  ...
  render :index
end

def pending
  ...
  render :index
end

# Ability

can :requested, Plan, dept_id: 304
can :pending, Plan, status: 'sent'

Where 'request' and 'pending' are two collection actions which should list the plans based on the respective filter. Problem is, if I don't add:

can :index, Plan

I get nothing. If I add this, it will show everything in both actions. In this cases, it seems that CanCan locks the actions, but is ignoring the conditions.

Any idea on how to solve this? Am I doing it wrong or not understanding something?

Thanks in advance.

@bryanrite
Copy link
Member

Hrm, the above should work, I use it in a few projects myself... Gimme a few days to take a look at it.

@Senjai Senjai self-assigned this Jun 13, 2015
@Senjai Senjai closed this as completed Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants