Nested Resource loads incorrectly in CanCan 1.6.6
When attempting to load_and_authorize a nested resource in version 1.6.6 it will attempt to load the nested resource using the parent resources id.
My controller looks like:
class DemoWebsitesController < ApplicationController
load_and_authorize_resource :potential_customer
load_and_authorize_resource :demo_website, :through => :potential_customer, :singleton => true
end
When trying to post to demo_websites#create the params would have: potential_customer_id => 6
I would then receive the error: ActiveRecord::RecordNotFound: Couldn't find DemoWebsite with id=6
There is no parameter id mind you. It is taking the potential_customer_id param, and using it as the id param.
Downgrading back to version 1.6.5 fixes the issue.
I can confirm this as well.
I confirm too. I killed a cat because of that.
Also happening to me.
Problem is in the new support for namespaced models from whilefalse: controller_resource.rb:207
I don't know how this is supposed to work though.
Confirmed here also. Had to revert to 1.6.5.
Same issue here.
Here, too
Same issue here as well. 1.6.6 broke the world :)
I'm also getting this issue...using 1.6.6
Downgraded to 1.6.5 to fix the issue.
The same here using 1.6.6, had to downgrade to 1.6.5 to fix it right away
Same error here. 1.6.6 should be yanked.
Sorry for the problem, I just released 1.6.7 with a quick fix and pulled 1.6.6. This issue was originally caused by this pull request.
https://github.com/ryanb/cancan/pull/424
The reason it got through the tests is because there was no controller name specified which matched an existing constant while loading the parent resource. The test case has been updated to handle this specific situation so it shouldn't crop up again.
That said, I think there's a better way to handle namespaced resources. If someone wants to submit a pull request feel free.
Thank a lot Ryan.
When will people start sending patches instead?
Ryan> Not sure if this is directly related.
I am trying to define ability for namespaced controller. I can not find any documentation on how to and find this instead.
https://github.com/galetahub/cancan_namespace/
I like the way it proposed to work, but don't know how well it works together with current version cancan 1.6.7.
Any recommendation or pointer?
Thanks,