I'm trying to load the resources using either load_resource or load_and_authorize_resource, but it doesn't seem to load the resource at all. I keep getting errors in my rspec controller test that @companies is nil or in my cucumber test that i can't cycle through @companies cause it's nil.
I'm using cancan straight from github repo at rev b4285ae
class CompaniesController < ApplicationController
# @companies = current_user.companies
@company = Company.new
I'm not sure if this will ultimately solve your problem (depending on the rest of your code), but the way you're currently using load_resource will not fetch companies from current_user. In order to fetch companies as a nested resource, you'll need to add a :through => :current_user attribute on load_resource, like so:
:through => :current_user
load_resource :through => :current_user
Still not working. It doesn't seem to load the resource at all, still.
Hey, is this still an issue?
As far as I know. I haven't tried again, still waiting for someone to take a look at this issue.
I recommend trying again with the most recent version of the gem to make sure it hasn't been fixed elsewhere.
If that doesn't help, please post your ability.rb file as well as the current_user method that CanCan relies on. The model file (which I assume is company.rb) would also be useful.
Dear submitter, Since cancan/raynB hasn't been active for more than 6 months and no body else then ryam himself has commit permissions the cancan project is on a stand still.
Since cancan has several issues including missing support for rails 4 cancan is moving forward to cancancan. More details on: #994
If your feel that your pull request or bug is still applicable (and hasn't been merged in to cancan) it would be really appreciated if you would resubmit it to cancancan (https://github.com/cancancommunity/cancancan)
We hope to see you on the other side!