Skip to content

Commit

Permalink
fix pluralize error on index action when passing resource name - closes
Browse files Browse the repository at this point in the history
ryanb#143 again
  • Loading branch information
ryanb committed Sep 8, 2010
1 parent 9d91545 commit a5ff826
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cancan/controller_resource.rb
Expand Up @@ -29,7 +29,7 @@ def load_resource
if !resource_instance && (parent? || member_action?) if !resource_instance && (parent? || member_action?)
@controller.instance_variable_set("@#{instance_name}", load_resource_instance) @controller.instance_variable_set("@#{instance_name}", load_resource_instance)
elsif load_collection? 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
end end


Expand Down
2 changes: 1 addition & 1 deletion spec/cancan/controller_resource_spec.rb
Expand Up @@ -67,7 +67,7 @@
it "should build a collection when on index action when class responds to accessible_by" do it "should build a collection when on index action when class responds to accessible_by" do
stub(Project).accessible_by(@ability) { :found_projects } stub(Project).accessible_by(@ability) { :found_projects }
@params[:action] = "index" @params[:action] = "index"
resource = CanCan::ControllerResource.new(@controller) resource = CanCan::ControllerResource.new(@controller, :project)
resource.load_resource resource.load_resource
@controller.instance_variable_get(:@project).should be_nil @controller.instance_variable_get(:@project).should be_nil
@controller.instance_variable_get(:@projects).should == :found_projects @controller.instance_variable_get(:@projects).should == :found_projects
Expand Down

0 comments on commit a5ff826

Please sign in to comment.