Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Michael Caputo
2,313 PointsBuild a Simple Ruby on Rails Application - Roadblock on Authentication System
Hi there, i'm new to Treehouse, and have really been enjoying it!
I've been running through the Ruby on Rails application videos, and I seem to have hit a road block. I'm wondering if the tutorial is out of date or something because it's not working as I expected it should be - up until now everything that the videos have been showing me has been true, however, once i've reached the part where I generate the Devise users auth system, I can't seem to reach the users/sign_up screen. It bumps me to the / page every time.. Any help?
28 Answers
Jody Albritton
Courses Plus Student 5,497 PointsAfter you bundle install and run the devise generators, make sure you stop and start your rails server.
Michael Caputo
2,313 PointsHey Jody, thanks for the reply.. I've done that a few times.
Jody Albritton
Courses Plus Student 5,497 PointsHave you done rake:routes to confirm that routes to the sign up pages were created?
You should have devise_for :users in your config/routes.rb
You should have /users/sign_up and /users/sign_in
Michael Caputo
2,313 Pointsthe routes are there
routes.rb is configured properly
however the views for users is not present. I'm not sure why these weren't created...
Jody Albritton
Courses Plus Student 5,497 PointsDevise views are not created automatically.
rails generate devise:views
Michael Caputo
2,313 PointsOk ok, it looks like the views WERE in fact created - I was looking in the views folder, but they were in the devise folder. My apologies.
I'm still not able to get into the users/sign_in or users/sign_up
Thank you for your help, it is much appreciated!
Jody Albritton
Courses Plus Student 5,497 PointsIs your code on github the code that is giving you problems?
Michael Caputo
2,313 PointsYes, right here: https://github.com/flashpunk/treebook
Jody Albritton
Courses Plus Student 5,497 PointsIn your routes config add
root :to => 'statuses#index'
near the bottom.
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect. Example: For a :user resource, it will use user_root_path if it exists, otherwise default root_path will be used. This means that you need to set the root inside your routes
Michael Caputo
2,313 PointsRight on, looks like that was it. In the video for "Installing Devise" the line where Jason adds this line to the routes is typed: root to: 'statuses#index'
Thanks, i knew it was probably some small detail that I missed.
Jody Albritton
Courses Plus Student 5,497 PointsNo problem. Have a good one.
Michael Caputo
2,313 PointsIs there any way of adding a note to that video where people can see the error in the line added? I would think that other people are having the same issue i'm seeing.
Michael Caputo
2,313 PointsIs there any way of adding a note to that video where people can see the error in the line added? I would think that other people are having the same issue i'm seeing.
Pasan Premaratne
Treehouse TeacherHey Jody & Michael. I pinged Jason on the issue so he's aware.
Jason Seifer
Treehouse Guest TeacherMichael, what was the exact error? Was it just missing the last root line?
Michael Caputo
2,313 PointsHi Jason, sorry I don't remember the exact error.
The video showed the line: root to: 'statuses#index'
But the solution was to use: root :to => 'statuses#index'
instead
Jason Seifer
Treehouse Guest TeacherIt's very strange that was causing an error. In versions of Ruby 1.9.2 and up, those are the exact same thing.
Jody Albritton
Courses Plus Student 5,497 PointsI did not see the error. I pointed out that the line was missing from his routes file. Adding the line back in is what solved the issue.
Mike Carlucci
1,982 PointsI'm having essentially the same problem. localhost:3000/users/sign_up goes back to / every time. I made the root :to => 'statuses#index' change but it is still giving me trouble.
Jody Albritton
Courses Plus Student 5,497 PointsIs your code on github?
Mike Carlucci
1,982 PointsI'm going through the first steps now to see if I missed something during the setup.
Jody Albritton
Courses Plus Student 5,497 PointsYour user model has some weird duplication going on. https://github.com/mikecarlucci/treebook/blob/master/app/models/user.rb
You should remove lines 2-12.
Mike Carlucci
1,982 PointsOk. I did that, still goes to the main page.
Jody Albritton
Courses Plus Student 5,497 PointsYou probably already have, but stop and start your rails server. Clear your browsers cache. etc.
After that can you copy and paste the last chunk of messages from the console?
Mike Carlucci
1,982 PointsThat did it. Didn't clear the cache the first time.
I'm thinking this should look normal:
Started GET "/users/sign_up" for 127.0.0.1 at 2012-12-20 10:59:12 -0500 Processing by Devise: :RegistrationsController#new as HTML Rendered devise/shared/_links.erb (2.8ms) Rendered devise/registrations/new.html.erb within layouts/application (17.7ms) Completed 200 Ok in 156ms (Views: 31.4ms | ActiveRecord: 0.5ms)
Jody Albritton
Courses Plus Student 5,497 PointsYep. That's what it should look like. Glad it was a simple fix.
Mike Carlucci
1,982 PointsMe too. Thanks!
Steven Swigart
4,191 PointsI was having a similar issue to the OP, I found that removing public/index.html solved the issue for me. (Which is what the Rails default homepage says to do.) Hope that helps!