Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails Tutorial - Routing error on '/sessions'
    primarykey
    data
    text
    <p>I am doing Michael Hartls Ruby on Rails Tutorial and I am getting a routing error when I try to browse to localhost:3000/sessions</p> <p>Routing Error</p> <p>No route matches "/sessions"</p> <p>From the tutorial, I was under the impression that rails will infer the route to "sessions" and I would not need to add a specification route to routes.rb.</p> <p>If I run rake routes I get the following</p> <pre><code> users GET /users(.:format) {:action=&gt;"index", :controller=&gt;"users"} POST /users(.:format) {:action=&gt;"create", :controller=&gt;"users"} new_user GET /users/new(.:format) {:action=&gt;"new", :controller=&gt;"users"} edit_user GET /users/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"users"} user GET /users/:id(.:format) {:action=&gt;"show", :controller=&gt;"users"} PUT /users/:id(.:format) {:action=&gt;"update", :controller=&gt;"users"} DELETE /users/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"users"} sessions POST /sessions(.:format) {:action=&gt;"create", :controller=&gt;"sessions"} new_session GET /sessions/new(.:format) {:action=&gt;"new", :controller=&gt;"sessions"} session DELETE /sessions/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"sessions"} root /(.:format) {:controller=&gt;"pages", :action=&gt;"home"} signup /signup(.:format) {:controller=&gt;"users", :action=&gt;"new"} signin /signin(.:format) {:controller=&gt;"sessions", :action=&gt;"new"} signout /signout(.:format) {:controller=&gt;"sessions", :action=&gt;"destroy"} about /about(.:format) {:controller=&gt;"pages", :action=&gt;"about"} contact /contact(.:format) {:controller=&gt;"pages", :action=&gt;"contact"} help /help(.:format) {:controller=&gt;"pages", :action=&gt;"help"} </code></pre> <p>My routes.rb contains</p> <pre><code>SampleApp::Application.routes.draw do resources :users resources :sessions, :only =&gt; [:new, :create, :destroy] root :to =&gt; 'pages#home' match '/signup', :to =&gt; 'users#new' match '/signin', :to =&gt; 'sessions#new' match '/signout', :to =&gt; 'sessions#destroy' match '/about', :to =&gt; 'pages#about' match '/contact', :to =&gt; 'pages#contact' match '/help', :to =&gt; 'pages#help' </code></pre> <p>I can get it to work if I add the following line to routes.rb, but I didn't think I needed to do this explicitly</p> <pre><code> match '/sessions',:to =&gt; 'sessions#create' </code></pre> <p>Am I missing something or misunderstanding something?<br> I am running Rails 3.0.11 and Ruby 1.9.2p290</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload