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 Creating an Authentication System Generating the User Model

Routing error from localhost:3000/users/sign_up

After performing:

rake db:migrate rake routes

everything seemed to look good. But when I enter localhost:3000/users/sign_up I get a page the says Routing Error and "No route matches [GET] "/users/sign_up" I've gone back over the steps a couple of times and can't figure out what I missed.

Does anyone know the fix for this? Thanks in advance!

3 Answers

Nick Fuller
Nick Fuller
9,027 Points

Hi Dinar,

In your routes file, it looks like you're missing the devise helper method. You want your routes file to look something like this:

Rails.application.routes.draw do
  devise_for :users

  resources :statuses

  root to: 'statuses#index'
end

Did you run the rails generate devise install and the rails generate devise User commands? The later is what injects the devise routes helper method into the routes.rb file for you.

Hello Nick-

I believe the rails generate devise install fixed that problem, although now I'm kicking out a new error when I try and access the localhost. So to update, my routes.rb now looks like this:

Rails.application.routes.draw do devise_for :installs devise_for :users resources :statuses root to: 'statuses#index' end

The new error is:

ActiveRecord::PendingMigrationError Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development Rails.root: /Users/dinardavis/treehouse/projects/treebook

I have run 'bin/rake db:migrate RAILS_ENV=development' and keep kicking out that error.

I also ran 'rake db:migrate:status' to show my pending migrations and got back the follow:

database: /Users/dinardavis/treehouse/projects/treebook/db/development.sqlite3

Status Migration ID Migration Name

up 20140523201625 Create statuses up 20140524225008 Devise create users down 20140525170951 Add devise to users down 20140525212904 Devise create installs

Which, unfortunately I have no idea what to do with. I have read that my Gems aren't matching up, but I don't really understand what that means, and don't know how to reconcile. Do you have any ideas?

Can you post a link to the project on GitHub or the actual code from your routes file and the text of what rake routes returns (in all its glorious detail)?

There are a few things that could be happening. The request could not be an HTTP "GET" request when you do rake routes and it is complaining about an HTTP action mismatch. You may also need to restart your server because you have it open from a previous version of the routes file and need to restart it to get the new changes and new routes.

Post the code on GitHub and share the link and we can see what is going on better.

Thanks for the response Matthew! I'm still trying to figure GitHub out, and the proper link to send. Below is the link I hope you need. But I've also copied the contents of the routes.rb file just in case.

https://github.com/dinarrene/treebook.git

Also, would you mind clarifying what you mean when you say "restart your sever?" Are you referring to the 'rails server/control C' start/stop commands, or is there another restart? Thank you again for your help.

resources :statuses root to: 'statuses#index'

# The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root" # root 'welcome#index'

# Example of regular route: # get 'products/:id' => 'catalog#view'

# Example of named route that can be invoked with purchase_url(id: product.id) # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically): # resources :products

# Example resource route with options: # resources :products do # member do # get 'short' # post 'toggle' # end # # collection do # get 'sold' # end # end

# Example resource route with sub-resources: # resources :products do # resources :comments, :sales # resource :seller # end

# Example resource route with more complex sub-resources: # resources :products do # resources :comments # resources :sales do # get 'recent', on: :collection # end # end

# Example resource route with concerns: # concern :toggleable do # post 'toggle' # end # resources :posts, concerns: :toggleable # resources :photos, concerns: :toggleable

# Example resource route within a namespace: # namespace :admin do # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products # end end

Here is what rake routes returns:

treebook dinardavis$ rake routes Prefix Verb URI Pattern Controller#Action 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 PATCH /users/password(.:format) devise/passwords#update 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 PATCH /users(.:format) devise/registrations#update 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 PATCH /statuses/:id(.:format) statuses#update PUT /statuses/:id(.:format) statuses#update DELETE /statuses/:id(.:format) statuses#destroy root GET / statuses#index treebook dinardavis$