Reputation: 15094
This issue has been previously reported, but I still have not been able to find a fix for it.
I have installed the plugin Devise on to my new RoR project. When I click on the sign up link, I am redirected to the following route:
http://localhost:3000/users/registration/sign_up
However, I obtain the following error:
undefined method `user_registration_path' for #<#<Class:0x007fd5d3503d58>:0x007fd5d3b0dcd0>
Extracted source (around line #5):
2: <h1>Sign up</h1>
3: </div>
4:
5: <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
6: <%= f.error_notification %>
7:
8: <div class="inputs">
My routes produces the following:
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session GET /users/sign_out(.:format) devise/sessions#destroy
password POST /users/password(.:format) devise/passwords#create {:name_prefix=>:user}
new_password GET /users/password/new(.:format) devise/passwords#new {:name_prefix=>:user}
edit_password GET /users/password/edit(.:format) devise/passwords#edit {:name_prefix=>:user}
PUT /users/password(.:format) devise/passwords#update {:name_prefix=>:user}
POST /users/registration(.:format) devise/registrations#create {:name_prefix=>"user_registration"}
new GET /users/registration/sign_up(.:format) devise/registrations#new {:name_prefix=>"user_registration"}
edit GET /users/registration/edit(.:format) devise/registrations#edit {:name_prefix=>"user_registration"}
PUT /users/registration(.:format) devise/registrations#update {:name_prefix=>"user_registration"}
DELETE /users/registration(.:format) devise/registrations#destroy {:name_prefix=>"user_registration"}
home_index GET /home/index(.:format) home#index
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
root / home#index
My routes.rb has the following code:
devise_for :users
get "home/index"
resources :users
root :to => "home#index"
Upvotes: 3
Views: 5735
Reputation: 18833
I had this issue and restarting the rails server fixed it for me
Upvotes: 12
Reputation: 167
Try this it might be help: if you mentioned any devise gem version remove that and keep only gem 'devise' and type bundle update command in terminal.
Upvotes: 0
Reputation: 15094
This problem is created when the devise version is 1.1.0 RC and you are running Rails 3.
Please look on how to upgrade your devise gem:
https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0
Hope this helps!
Upvotes: 0
Reputation: 21559
UPDATED: I think you have to specify the "METHOD" as "POST" of the form.
5: <%= simple_form_for(resource, :as => resource_name,
6: :url => registration_path(resource_name),
7: :method => :POST) do |f| %>
================ (deprecated answer below)
I think you have problems in your config/routes.rb file. the expected output is :
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
so make sure your config/routes.rb has this linke of code:
devise_for :users
Upvotes: 1