Reputation: 4007
I'm stuck in a Rails tutorial trying to configure Rails routes.
This is my routes.rb:
SampleApp::Application.routes.draw do
match '/', :to => 'static_pages#home', :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
When I try to access "localhost" I get:
No route matches [GET] "/static_pages/help" Try running rake routes for more information on available routes.
I also tried:
match '/', :to => 'static_pages#home'
match '/help',:to => 'static_pages#help'
match '/about', :to => 'static_pages#about'
match '/contact', :to => 'static_pages#contact'
but that gives the same error. It only works when I use:
get 'static_pages/about'
How can I get localhost to work?
Upvotes: 1
Views: 841
Reputation: 1
Try this:
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
Upvotes: 0
Reputation: 2060
Try putting the following at the end of routes.rb
match ':action' => 'static#:action'
A request to /help
will then render app/views/static/help.html.erb
. Don't forget to create the static
controller though, even if it's empty.
Upvotes: 0