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

Issue w/ Treebook Sign Up Screen

I'm working on the Treebook project, and I'm at the point in the project where you install devise and generate the different fields for signing up an account. I had the http://0.0.0.0:3000/users/sign_up page rendered properly, went through the process shown in the video of destroying the user, etc. but now when i try to go back to the same url it takes me to the main server screen that says "You're riding Ruby on Rails!" The /statuses url still works just fine. It does, however, say at the top of the page "You are already signed in."

Help!

5 Answers

Oh, ok... I got it now. You're already signed in, so when you visit the /users/sign_up page it redirects to the homepage / with an alert at the top that says "You are already signed in.". You need to log-out in order to access the /users/sign_up page. If you haven't already created the Sign out link, Jim will do that in one of the upcoming videos.

For the time being to sign out, delete the cookie in your browser that the Treebook app created when you signed up or signed in. Then it should display the sign up page properly.

Thanks so much, Steve! I'm new at this. I appreciate your patience.

At the console type rake routes to see if anything looks off there and post it here. I would also take a look at config/routes.rb. The top should look like this:

devise_for :users

resources :statuses
root to: 'statuses#index'

Also, you will need to delete /public/index.html so it doesn't override the root to: 'statuses#index' route.

Here is what I got from the rake routes command:

NameError: undefined local variable or method routes' for main:Object from (irb):1 from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:47:instart' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in start' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:41:in<top (required)>' from script/rails:6:in require' from script/rails:6:in<main>'

I also checked config/routes.rb and everything looks good there. I also deleted the /public/index.html file and now when I try to navigate to users/sign_up it just refreshes the statuses page.

Sorry, when I said type rake routes at the 'console' I meant the command line... bash shell... where you type in rails server and those sorts of commands. Not the rails console. Sorry about that. Try it again and re-post. You should get something other than an error now.

Okay, this is what rake routes gives me from the command line on terminal:

new_user_session GET /users/sign_in(.:format) devise/sessions#new user_session POST /users/sign_in(.:format) devise/sessions#create destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy user_password POST /users/password(.:format) devise/passwords#create new_user_password GET /users/password/new(.:format) devise/passwords#new edit_user_password GET /users/password/edit(.:format) devise/passwords#edit PUT /users/password(.:format) devise/passwords#update 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 PUT /users(.:format) devise/registrations#update DELETE /users(.:format) devise/registrations#destroy statuses GET /statuses(.:format) statuses#index POST /statuses(.:format) statuses#create new_status GET /statuses/new(.:format) statuses#new edit_status GET /statuses/:id/edit(.:format) statuses#edit status GET /statuses/:id(.:format) statuses#show PUT /statuses/:id(.:format) statuses#update DELETE /statuses/:id(.:format) statuses#destroy root / statuses#index

Okay, it gets stranger. If I destroy the user, I can access the sign up page again with no trouble. Anyone?

Yes, that would make sense. See my answer below. You just needed to sign out, but you probably don't have the link to do that yet in the app. Destroying the user in the database achieves the same thing. i.e. No user account in db, therefore session is invalidated and you're effectively 'signed out'.