Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified CanCan::ControllerResource#namespace in order to use '/' as …

…a separator instead of '::'
  • Loading branch information...
commit 725e6c71ad5042ac6a5214fafaf0fc448bf4afe7 1 parent 3f4ee12
@pic authored
View
2  lib/cancan/controller_resource.rb
@@ -225,7 +225,7 @@ def resource_params_by_namespaced_name
end
def namespace
- @params[:controller].split("::")[0..-2]
+ @params[:controller].split("/")[0..-2]
end
def namespaced_name
View
4 spec/cancan/controller_resource_spec.rb
@@ -41,7 +41,7 @@ class Project < ::Project; end
end
project = MyEngine::Project.create!
- @params.merge!(:controller => "MyEngine::ProjectsController", :action => "show", :id => project.id)
+ @params.merge!(:controller => "my_engine/projects", :action => "show", :id => project.id)
resource = CanCan::ControllerResource.new(@controller)
resource.load_resource
@controller.instance_variable_get(:@project).should == project
@@ -53,7 +53,7 @@ module MyEngine
class Project < ::Project; end
end
- @params.merge!(:controller => "MyEngine::ProjectsController", :action => "create", :my_engine_project => {:name => "foobar"})
+ @params.merge!(:controller => "my_engine/projects", :action => "create", :my_engine_project => {:name => "foobar"})
resource = CanCan::ControllerResource.new(@controller)
resource.load_resource
@controller.instance_variable_get(:@project).name.should == "foobar"
Please sign in to comment.
Something went wrong with that request. Please try again.