0

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?

3 Answers 3

3

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'

see http://guides.rubyonrails.org/routing.html

Sign up to request clarification or add additional context in comments.

1 Comment

The key: value syntax only works in Ruby 1.9 or greater. The to syntax is perfectly valid, but will need to use :to => static_pages#help in Ruby 1.8.
2

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.

Comments

0

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]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.