Routing Error in Chapter 7.1.2 of the Ruby on Rails Tutorial
Posted
by
user2985910
on Stack Overflow
See other posts from Stack Overflow
or by user2985910
Published on 2013-11-13T03:28:38Z
Indexed on
2013/11/13
3:53 UTC
Read the original article
Hit count: 212
I've been working through the tutorial for the past few days, and finally hit a snag in chapter 7.
It is in this step where the line in routes.rb:
get "users/new"
is replaced with
resource :users
After I do this, I get a routing error when visiting
http://localhost:3000/users/1 - No route matches [GET] "/users/1"
instead of the other "Unknown Action" error shown here.
Per the instructions, my routes.db file looks like this:
SampleApp::Application.routes.draw do
resource :users
root "static_pages#home"
match '/signup', to: 'users#new', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/about', to: 'static_pages#about', via: 'get'
match '/contact', to: 'static_pages#contact', via: 'get'
end
Output from 'rake routes' shows:
Prefix Verb URI Pattern Controller#Action
users POST /users(.:format) users#create
new_users GET /users/new(.:format) users#new
edit_users GET /users/edit(.:format) users#edit
GET /users(.:format) users#show
PATCH /users(.:format) users#update
PUT /users(.:format) users#update
DELETE /users(.:format) users#destroy
root GET / static_pages#home
signup GET /signup(.:format) users#new
help GET /help(.:format) static_pages#help
about GET /about(.:format) static_pages#about
contact GET /contact(.:format) static_pages#contact
Does anyone have any insight to get past this? Many thanks.
© Stack Overflow or respective owner