Skip to content
This repository

getting namespace in CanCan::ControllerResource #680

Closed
joxxoxo opened this Issue · 2 comments

2 participants

Andrey Rozhkovsky Anuj Dutta
Andrey Rozhkovsky

It parses @params[:controller] for namespace wrong.

    def namespace
      @params[:controller].split("::")[0..-2]
    end

There are specs

it "should attempt to load a resource with the same namespace as the controller when using :: for namespace" 
it "should properly load resource for namespaced controller"  # which uses 'admin/projects'

in fact controller name in params uses 'namespace/name' format

so i used monkeypatch which fixed this for me

CanCan::ControllerResource.class_eval do
  def namespace
    @params[:controller].split(/::|\//)[0..-2]
  end
end
Anuj Dutta
Collaborator

@joxxoxo: This was fixed by this pull request (#675) that will be merged into master very soon.

Anuj Dutta andhapp closed this
Andrey Rozhkovsky

sorry that i haven't noticed that.
actually i've tried that solution and some specs failed, then i've come to this: #681
could you look at that one too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.