0

I am very new to rails an d I have this in my model

PreGit::Application.routes.draw do

  resources :microposts
  resources :users

  match '/help',    to:'static_pages#help'
  match '/about',   to:'static_pages#about'
  match '/contact', to:'static_pages#contact'

  root_path => '/'
  root_url => 'http://localhost:3000/'

end

But when running bundle exec rake db:migrate I get that :

syntax error, unexpected tSYMBEG, expecting kDO or '{' or '('
  match '/help',    to:'static_pages#help'
                    ^

Someone could help

1 Answer 1

1

It seems like this is not a Rails issue but a Ruby version issue.

In Ruby 1.8.x the hash syntax was

:to => static_pages#help'

but Ruby 1.9.x supports

to:'static_pages#help'

so probably you are trying to run an app developed under Ruby 1.9.x under your Ruby 1.8.x

Try running the same app under Ruby 1.9.x

If you are using rvm then try this

rvm list #will list all your ruby versions

If you have ruby 1.9.x installed

rvm use ruby-1.9.x
4
  • In fact, I realized it worked only when deleting these two lines root_path => '/' root_url => 'localhost:3000 but when I add these I get syntax error, unexpected tASSOC, expecting keyword_end root_url => 'localhost:3000' ^ Do you have an idea ? Jan 1, 2013 at 4:15
  • normally in routes.rb you define the root url as root :to => '<controller>#action', Ex: root :to => '/' and hope u r using rails 3.x, I'm not sure why u have two root urls.
    – sameera207
    Jan 1, 2013 at 4:25
  • Hi again @sameera207, I added this root :to => '/', and I got that : .rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.9/lib/action_dispatch/routing/mapper.rb:174:in `default_controller_and_action': controller name should not start with a slash (ArgumentError) Jan 4, 2013 at 22:55
  • Hi , change the root_to => 'static_pages#help' and see how it goes, the syntax is <controller>#<action> :)
    – sameera207
    Jan 5, 2013 at 5:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.