AnApprentice
AnApprentice

Reputation: 110940

Rails 3 - CanCan error? NameError (uninitialized constant Ability::Invitation):

Error:

NameError (uninitialized constant Ability::Invitation):
  app/models/ability.rb:72:in `initialize'
  app/controllers/invitations_controller.rb:12:in `new'
  app/controllers/invitations_controller.rb:12:in `current_ability'
  app/middleware/flash_session_cookie_middleware.rb:14:in `call'

In CanCan i have:

can :manage, Invitation

in the Invitations Controller:

before_filter :current_ability # CanCan load_and_authorize_resource #CanCan

def current_ability @current_ability ||= Ability.new(current_user, nil) end

Application's controller:

#CanCan
def current_ability
    @current_ability ||= Ability.new(current_user, nil) # since no group
end

Routes:

resources :invitations

Any thoughts why CanCan isn't happy? thanks

Upvotes: 2

Views: 3554

Answers (1)

Ryan Bigg
Ryan Bigg

Reputation: 107708

Looks like you are trying to reference a class that is not defined. Is there a file at app/models/invitation.rb that defines this Invitation class?

Upvotes: 9

Related Questions