Reputation: 3053
So, I have never used devise before and am trying to implement it in my program via http://railscasts.com/episodes/209-introducing-devise. I installed it and everything word for word as this guy did and then when I try and go to http://localhost:3000/users/sign_up, I get this error:
Routing Error
No route matches [GET] "/users/sign_up"
here is what I get when I do rake route:
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
POST /users/registration(.:format) {:action=>"create", :controller=>"devise/registrations"}
new GET /users/registration/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit GET /users/registration/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users/registration(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users/registration(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
vote_post POST /posts/:id/vote(.:format) {:action=>"vote", :controller=>"posts"}
posts GET /posts(.:format) {:action=>"index", :controller=>"posts"}
POST /posts(.:format) {:action=>"create", :controller=>"posts"}
new_post GET /posts/new(.:format) {:action=>"new", :controller=>"posts"}
edit_post GET /posts/:id/edit(.:format) {:action=>"edit", :controller=>"posts"}
post GET /posts/:id(.:format) {:action=>"show", :controller=>"posts"}
PUT /posts/:id(.:format) {:action=>"update", :controller=>"posts"}
DELETE /posts/:id(.:format) {:action=>"destroy", :controller=>"posts"}
root / {:controller=>"users", :action=>"index"}
If you watch the video the guy is just able to go to that web address and it just works. I noticed that there is a [GET] /users/registration/sign_up(.:format) but no [GET] /users/sign_up like the guy in the video has. Is there something I am missing?
p.s.
this is the error I get when I try to go to one of the routes listed above (user/sign_in):
NoMethodError in Devise/registrations#new
Showing /Users/davidfleischhauer/.rvm/gems/ruby-1.9.2-p290/gems/devise- 1.1.rc0/app/views/devise/registrations/new.html.erb where line #3 raised:
undefined method `user_registration_path' for #<#<Class:0x007f85eafec758>:0x007f85eaf77ed0>
Upvotes: 3
Views: 4641
Reputation: 2364
add to routes.rb this is:
devise_for :users do
get'users/sign_out'=>'devise/sessions#destroy'
end
it's for sign_out
for sign_up go to config/initializers/secret_token.rb
and copy line: config.secret_token ='...'
and paste it in config/aplication.rb
Upvotes: 0
Reputation: 3153
I am trying to figure out why you are using Devise version 1.1rc0 and not the latest gem available which is 1.4.7? I have several applications all running this latest version in which the sign_up
path works just fine. I would recommend updating to the latest version of the gem and try again. Outside of that, I can only think of problems that could be caused by something in your routes.rb
file or if you are trying to override the Devise Registrations Controller.
Upvotes: 0
Reputation: 2752
You have to use new_user_registration_path in order to create a link to the sign up page. You have to use new_user_session_path in order to create a link to sign_in.
Upvotes: 2
Reputation: 160271
Bear in mind the video is a year+ old :)
If you look at the current devise source where the routes are generated you'll see that it apparently no longer creates a "sign_up" route--looks like the registration paths are the current method.
It also looks like you're using a release candidate version, which always makes me a little nervous, since that's a release candidate and not necessarily 100% stable--which might explain why the default template is using a path variable that doesn't exist.
Upvotes: 1