Skip to content

getting namespace in CanCan::ControllerResource #680

Closed
joxxoxo opened this Issue Jul 5, 2012 · 2 comments

2 participants

@joxxoxo
joxxoxo commented Jul 5, 2012

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
@andhapp
Collaborator
andhapp commented Jul 5, 2012

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

@andhapp andhapp closed this Jul 5, 2012
@joxxoxo
joxxoxo commented Jul 5, 2012

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.