Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

NameError in Controller + Pluralize #880

Open
renatojf opened this issue Jun 11, 2013 · 2 comments
Open

NameError in Controller + Pluralize #880

renatojf opened this issue Jun 11, 2013 · 2 comments

Comments

@renatojf
Copy link

When you have a controller named differently from rails pluralize pattern (i.e. "Imovel" model and "Imoveis" controller) you will get this error because CanCan tries to reference a model named "Imovei".

Dunno if it was clear enough but I can provide more details if needed.

Using CanCan 2.0 btw

@renatojf
Copy link
Author

I realized my error and stopped using 'load_and_authorize_resource' and started using the application controller line 'enable_authorization' but it's still broken because now I get segmentation faults, crashing the server.
This is a snippet of how I'm doing and getting the seg fault:

Ability.rb

if user.admin?
  can :access, :all
else
  can :access, :imoveis
end

ApplicationController

class ApplicationController < ActionController::Base
    enable_authorization

So, as a guest user, when I try to access '/imoveis' or any other url besides '/imoveis/new' I get a segmentation fault. When I try to access '/imoveis/new' I get this error:

stack level too deep

Rails.root: /home/renatojf/Documents/Code/thedoors
Application Trace | Framework Trace | Full Trace

actionpack (4.0.0.rc1) lib/action_dispatch/middleware/reloader.rb:70

And this is a small log of the segfault:

c:0083 p:0008 s:0448 e:000447 METHOD /home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:287
c:0082 p:0037 s:0443 e:000441 BLOCK  /home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:288 [FINISH]
c:0081 p:---- s:0439 e:000438 CFUNC  :map
c:0080 p:0008 s:0436 e:000435 METHOD /home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:287
c:0079 p:0015 s:0431 e:000429 BLOCK  /home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:311 [FINISH]
c:0078 p:---- s:0426 e:000425 IFUNC 
c:0077 p:---- s:0424 e:000423 CFUNC  :each
c:0076 p:---- s:0422 e:000421 CFUNC  :each_with_object

...

/home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:287:in `map'
/home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:288:in `block in expand_aliases'
/home/renatojf/.rvm/gems/ruby-2.0.0-p195@thedoors/bundler/gems/cancan-e6bf4c8d12dc/lib/cancan/ability.rb:287:in `expand_aliases'

@xhoy
Copy link

xhoy commented Jul 1, 2014

Thanks for your submission! The ryanb/cancan repository has been inactive since Sep 06, 2013.
Since only Ryan himself has commit permissions, the CanCan project is on a standstill.

CanCan has many open issues, including missing support for Rails 4. To keep CanCan alive, an active fork exists at cancancommunity/cancancan. The new gem is cancancan. More info is available at #994.

If your pull request or issue is still applicable, it would be really appreciated if you resubmit it to CanCanCan.

We hope to see you on the other side!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants