我已经开始使用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