I am getting this error while going through the tutorial by Michael Hartl. Section 5.3.2 (Rails routes).
Content of my routes.rb file is
SampleApp::Application.routes.draw do
root 'static_pages#home'
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
My rspec at static_pages is successful ..I have followed every instructions but still getting this error while trying to access any of the pages at `
http://localhost:3000/static_pages/home
http://localhost:3000/static_pages/about
http://localhost:3000/static_pages/contact
This is the error i am getting on these pages
Action Controller:Exception caught
Routing Error
No route matches [GET] "/static_pages/about"
Rails.root: /home/abhinay/rails_projects/sample_app
Application Trace | Framework Trace | Full Trace
Routes
Routes match in priority from top to bottom
Helper HTTP Verb Path Controller#Action
Path / Url
root_path GET / static_pages#home
help_path GET /help(.:format) static_pages#help
about_path GET /about(.:format) static_pages#about
contact_path GET /contact(.:format) static_pages#contact
Look you do not have any routes "/static_pages/about"
so you got error
Routing Error
No route matches [GET] "/static_pages/about"
As per your routes for about page /about
should be the url
http://localhost:300/about
http://localhost:300/contact
http://localhost:300/help
It will acutally call your static_pages
controller and about
action of that controller
and from url helper of rails routes you get
For About:
about_path
or about_url
should be used
For contact
contact_path
or contact_url
For help
help_path
or help_url