Question

Invitations Controller

class InvitationsController < Devise::InvitationsController

 def new
 end

 def create
 end

end

routes.rb

  devise_for :users, :controllers => { :invitations => 'users/invitations' }

application_controller

class ApplicationController < ActionController::Base
 # Prevent CSRF attacks by raising an exception.
 # For APIs, you may want to use :null_session instead.
 protect_from_forgery with: :exception
 before_filter :configure_permitted_parameters, if: :devise_controller?

 protected

 def configure_permitted_parameters
 # Only add some parameters
 devise_parameter_sanitizer.for(:accept_invitation).concat [:email]
 # Override accepted parameters
 devise_parameter_sanitizer.for(:accept_invitation) do |u|
  u.permit(:email, :password, :password_confirmation,
         :invitation_token)
 end
end

users_controller

def new
 @user = User.new(:invitation_token => params[:invitation_token])
 @user.email = @user.invitation.recipient_email if @user.invitation
end

When I go to the '/users/invitation/new I get the error 'uninitialized constant Users'. What am I missing? Thanks

Was it helpful?

Solution

try

devise_for :users, :controllers => { :invitations => 'invitations' }

instead, also if you override the methods , you probably need to call the parent , by using super like this:

```

class InvitationsController < Devise::InvitationsController

   def new
     super
   end

end

```

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top