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

Ruby

Build 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

After you bundle install and run the devise generators, make sure you stop and start your rails server.

Hey Jody, thanks for the reply.. I've done that a few times.

Have 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

the 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...

Devise views are not created automatically.

rails generate devise:views

Ok 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!

Is your code on github the code that is giving you problems?

In 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

https://github.com/plataformatec/devise

Right 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.

No problem. Have a good one.

Is 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.

Is 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
STAFF
Pasan Premaratne
Treehouse Teacher

Hey Jody & Michael. I pinged Jason on the issue so he's aware.

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Michael, what was the exact error? Was it just missing the last root line?

Hi 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
STAFF
Jason Seifer
Treehouse Guest Teacher

It's very strange that was causing an error. In versions of Ruby 1.9.2 and up, those are the exact same thing.

I 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.

I'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.

Is your code on github?

it is

I'm going through the first steps now to see if I missed something during the setup.

Your 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.

Ok. I did that, still goes to the main page.

You 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?

That 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)

Yep. That's what it should look like. Glad it was a simple fix.

Me too. Thanks!

I 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!