Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Shallow not working in Rails 4 #985

Open
JoshuaNovak919 opened this issue Jan 17, 2014 · 2 comments
Open

Shallow not working in Rails 4 #985

JoshuaNovak919 opened this issue Jan 17, 2014 · 2 comments

Comments

@JoshuaNovak919
Copy link

When loading and authorizing a resources through another and using the option shallow an error is thrown saying it can't find the id of the parent. I'm assuming this has to do with the permit changes in Rails 4.

@windmillium
Copy link

I'm having a similar problem, here's how I fixed it:

class LeadsController < ApplicationController
  load_and_authorize_resource :student, only: [:index, :new, :create]
  load_and_authorize_resource :lead, :through => :student, :shallow => true
end

@willkoehler
Copy link

This is also a problem in Rails 3.2.16. I believe it's a regression in v1.6.10. The fix @windmillium suggests also works in Rails 3.2.16. Thanks!

If you don't want to add an unnecessary "only" clause, #989 Fixes this problem - and many others. You can use that fork by changing the cancan line in your gemfile:

gem 'cancan', :git => '[email protected]:bryanrite/cancan.git', :ref => '014f51307fa34d42602e71fa86724f532504f6a2'

BTW this problem is also discussed in #955 and #983 (and maybe others?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants