2015-08-15 131 views
3

我嘗試我的第一個Rails應用程序ROR:語法錯誤,意想不到的tSTRING_BEG,期待keyword_do或 '{' 或 '('(的SyntaxError)

但得到了以下錯誤:

/Users/WWW/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load': /Users/WWW/railsbridge/first-app/config/routes.rb:3: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError) 
+ get 'welcome',to: 'topics#welcome' 
    ^
/Users/WWW/railsbridge/first-app/config/routes.rb:3: syntax error, unexpected ',', expecting keyword_end 
+ get 'welcome',to: 'topics#welcome' 

這裏是代碼:

resources :topics 
+ get 'welcome',to: 'topics#welcome' 

回答

0

以及閱讀的指南,以幫助您開始如上面提到的,還讀代碼所提供的意見,以幫助您開始。該文件的routes.rb是一個很好的例子:

# The priority is based upon order of creation: first created -> highest priority. 
    # See how all your routes lay out with "rake routes". 

    # You can have the root of your site routed with "root" 
    # root 'welcome#index' 

    # Example of regular route: 
    # get 'products/:id' => 'catalog#view' 

    # Example of named route that can be invoked with purchase_url(id: product.id) 
    # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase 

等等

相關問題