Rob
Rob

Reputation: 109

Devise Registration URL could not be found

I have a problem with devise after customizing the signup - route. The devise doc mentions, that routes can easily be customized, so I tried to add a token to the URL to set up a easy invitation system. Ist really straight forward and all I did was adding

devise_for :users, :path_names => { :sign_up => "signup/:invitation_token" }

to my routes. A mailer sends an email with the token and inside I pass

new_user_registration_path(@invitation.token)

rake routes says

 new_user_registration GET    /users/signup/:invitation_token(.:format)     devise/registrations#new

But I'm still getting

 No route matches {:action=>"new", :controller=>"devise/registrations", :locale=>:de, :invitation_token=>nil}

I get it wether I pass the token or not...

I'm not shure what I'm missing. Thanks in advance, hope someones sees what I'm doing wrong.

Greets, Rob

Upvotes: 0

Views: 260

Answers (1)

zeantsoi
zeantsoi

Reputation: 26203

Check @invitation.token to make sure that it's not nil.

The error you're witnessing will occur on any view in which you pass nil into your new_user_registration_path link tag.

Bear in mind that you'll need to override the default behavior of Devise's users/registration controller in order to get your invitation system working correctly. Something like this would work:

# routes.rb
devise_for :users, :path_names => { :sign_up => "signup/:invitation_token" }, :controllers => {:registrations => "users/registrations"}

# app/controllers/users/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
    def create
        # add custom create logic here
    end
end

Upvotes: 1

Related Questions