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

skip_authorize_resource not inheritable #391

Closed
iamdriz opened this issue Jan 25, 2017 · 13 comments
Closed

skip_authorize_resource not inheritable #391

iamdriz opened this issue Jan 25, 2017 · 13 comments
Assignees

Comments

@iamdriz
Copy link

iamdriz commented Jan 25, 2017

Any reason why skip_authorize_resource isn't inheritable?
For example I have an ApplicationController with it in and a PagesController that inherits from ApplicationController like so:

class ApplicationController < ActionController::Base
  skip_authorize_resource
end
class PagesController < ApplicationController
  def index
  end
end

The methods inside PagesController don't skip! So PagesController isn't inheriting skip_authorize_resource.

But doing this:

class ApplicationController < ActionController::Base
  skip_authorize_resource
end
class PagesController < ApplicationController
  skip_authorize_resource #shouldn't this have been inherited from ApplicationController?

  def index
  end
end

Does work... why isn't skip_authorize_resource inherited? As I'd prefer to avoid having to add that line to all my subcontrollers if possible.

The reason for doing it is because of this issue: #390

@benkoshy
Copy link
Contributor

benkoshy commented Feb 3, 2017

@iamdriz hello - i could not discern the different between the two code examples. would you pls elaborate?

@iamdriz
Copy link
Author

iamdriz commented Feb 3, 2017

@BKSpurgeon Sorry forgot to add the correct code. Basically as you can see I've had to add the skip_authorize_resource to both controllers. But expected PagesController to have inherited it from ApplicationController but it doesn't.

@benkoshy
Copy link
Contributor

benkoshy commented Feb 4, 2017

I'll try and look into it. i can't guarantee success tho. pls bear with me.

@iamdriz
Copy link
Author

iamdriz commented Feb 6, 2017

@BKSpurgeon skip_authorize_resource basically just needs to be inheritable same as the load_and_authorize_resource methods.

@benkoshy
Copy link
Contributor

benkoshy commented Feb 8, 2017

@iamdriz bro gimme till the weekend i have not forgotton. then i'll tell you whether i could or couldn't do it

Ben

@iamdriz
Copy link
Author

iamdriz commented Feb 22, 2017

@BKSpurgeon You have any luck with it?

@benkoshy
Copy link
Contributor

@iamdriz bro don't wait by the phone.........i've simply been inundated......i can't promise to find the solution -- i've yet to seriously look at the gem -- by Monday you'll know for sure whether i can solve it or not. i hope i can. btw can github do PMs?

@enneid
Copy link

enneid commented Feb 27, 2017

workaround:

class ApplicationController < ActionController::Base
 def self.inherited(subclass)
      subclass.skip_authorize_resource 
    end
end

@coorasse
Copy link
Member

is this issue solved in cancancan 2.0?

@coorasse coorasse self-assigned this Jul 14, 2017
@benkoshy
Copy link
Contributor

to fix would probably need a significant work around of existing code base.

@iamdriz
Copy link
Author

iamdriz commented Sep 27, 2017

@coorasse I've only tested this on CanCanCan 2.0 so I'd say not.

@kraflab
Copy link
Contributor

kraflab commented Feb 17, 2018

Looks like this was already solved here: 1f78627 ?

@coorasse
Copy link
Member

should be fixed, agree.

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

5 participants