我已經開始使用http://guides.rubyonrails.org/getting_started.html學習Ruby on Rails。我絕不是編程新手,但Ruby on Rails與我以前的不同。Rake中止語法錯誤Ruby
我在第5步,需要創建新的文章資源。當我修改配置/ routes.rb中文件看起來像這樣:
Blog2::Application.routes.draw do
get "welcome/index"
Blog2::Application.routes.draw do
resources :posts
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
#
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
#root :to => 'articles#new'
root :to => 'welcome#index'
end
我不斷收到在耙路線錯誤,它說:
rake aborted!
SyntaxError: C:/rubygems/blog2/config/routes.rb:68: syntax error, unexpected $en
d, expecting keyword_end
C:in execute_if_updated' C:/rubygems/blog2/config/environment.rb:5:in'
Tasks: TOP => routes => environment
(See full trace by running task with --trace)
我知道這是行68和有事用「結束」來做,但我已確定「結束」未註釋。
有誰知道這個問題是什麼?
你的文件中顯然比少數幾行更多。該塊示例在語法上有效,但您的實際文件不是。 – tadman 2014-11-06 15:26:59
錯誤信息說錯誤發生在你的'config/routes.rb'文件的第68行。顯示此文件中的所有內容。 – 2014-11-06 15:27:17
檢查您的整個'routes.rb'文件是否有不正確的塊。第68行就是Ruby無法從語法上理解文件的地方。但錯誤可能在此之前的任何地方。 – lurker 2014-11-06 15:27:19