Open JoshuaNovak919 opened 10 years ago
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
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 => 'git@github.com:bryanrite/cancan.git', :ref => '014f51307fa34d42602e71fa86724f532504f6a2'
BTW this problem is also discussed in #955 and #983 (and maybe others?)
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.