When creating my application using ROR, I continually receive a syntax error when I use:
FitsbyApp::Application.routes.draw do
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
end
I am using Rails 3.2.8. Could it be that I don't have the right version of Rails or Ruby?
This is the error I get when I run the match:
rb:245:in `load': /Users/dannygaeta/rails_projects/fitsby_app/config/routes.rb:2: syntax error, unexpected ':', expecting kEND (SyntaxError)
I get this for each match. Any ideas what I am doing wrong?
The error you're getting is (probably) from the trailing colon in to:
. That said, I'm no rails expert but shouldn't the route in question look like this?
match '/help' => 'static_pages#help'
This sounds like you're using ruby 1.8.x. Ruby 1.9 introduced a new syntax for hashes,
match 'foo', to: 'bar'
Is the same as
match 'foo', :to => 'bar'
Your routes file appears to be using the newer syntax.
In Rails 3:
match 'logout' => 'user_sessions#destroy', :as => :logout
OR
match '/help' => 'static_pages#help'
In Rails 4:
match 'logout' => 'user_sessions#destroy', :as => :logout, via: [:get, :post]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.