From 245b83f6b443a25d8563f94f2d4a563ac6583576 Mon Sep 17 00:00:00 2001 From: Oliver Morgan Date: Thu, 31 May 2012 10:45:55 +0100 Subject: [PATCH] Classify causes plural model names to be incorrectly renamed Some model names will be renamed incorrectly e.g. 'business'. It should be the responsibility of the user to make sure they use a name that directly corresponds to the model name. The only filtering performed should be camelize. --- lib/cancan/controller_resource.rb | 2 +- spec/cancan/controller_resource_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cancan/controller_resource.rb b/lib/cancan/controller_resource.rb index ca5b446..1d6a3e0 100644 --- a/lib/cancan/controller_resource.rb +++ b/lib/cancan/controller_resource.rb @@ -145,7 +145,7 @@ module CanCan def resource_class case @options[:class] when false then name.to_sym - when nil then (@name || namespaced_name).to_s.classify.constantize + when nil then (@name || namespaced_name).to_s.camelize.constantize when String then @options[:class].constantize else @options[:class] end diff --git a/spec/cancan/controller_resource_spec.rb b/spec/cancan/controller_resource_spec.rb index 07294b2..5a2981e 100644 --- a/spec/cancan/controller_resource_spec.rb +++ b/spec/cancan/controller_resource_spec.rb @@ -222,8 +222,8 @@ describe CanCan::ControllerResource do } @controller.instance_variable_get(:@project).should be_nil end - - it "named resources should not be loaded independently of the controller" do + + it "named resources should be loaded independently of the controller name" do category = Category.create! @params.merge!(:action => "new", :category_id => category.id)