diff --git a/lib/cancan/controller_resource.rb b/lib/cancan/controller_resource.rb index 84145e3..27ff1de 100644 --- a/lib/cancan/controller_resource.rb +++ b/lib/cancan/controller_resource.rb @@ -29,7 +29,7 @@ module CanCan if !resource_instance && (parent? || member_action?) @controller.instance_variable_set("@#{instance_name}", load_resource_instance) elsif load_collection? - @controller.instance_variable_set("@#{instance_name.pluralize}", load_collection) + @controller.instance_variable_set("@#{instance_name.to_s.pluralize}", load_collection) end end diff --git a/spec/cancan/controller_resource_spec.rb b/spec/cancan/controller_resource_spec.rb index 3ec37dd..7e490ca 100644 --- a/spec/cancan/controller_resource_spec.rb +++ b/spec/cancan/controller_resource_spec.rb @@ -67,7 +67,7 @@ describe CanCan::ControllerResource do it "should build a collection when on index action when class responds to accessible_by" do stub(Project).accessible_by(@ability) { :found_projects } @params[:action] = "index" - resource = CanCan::ControllerResource.new(@controller) + resource = CanCan::ControllerResource.new(@controller, :project) resource.load_resource @controller.instance_variable_get(:@project).should be_nil @controller.instance_variable_get(:@projects).should == :found_projects