簡體   English   中英

語法錯誤,意外的tIDENTIFIER,期待keyword_end

[英]syntax error, unexpected tIDENTIFIER, expecting keyword_end

rb文件代碼

SampleApp::Application.routes.draw do
  get "static_pages/home"


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


  # 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
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => 'welcome#index'

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id))(.:format)'
end

它向我顯示錯誤

syntax error, unexpected tIDENTIFIER, expecting keyword_end
match '/contact' to:'static_pages#contact'
                   ^
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `block in load'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `each'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/file_update_checker.rb:78:in `call'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/file_update_checker.rb:78:in `execute'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/ritesh/projects/sample_app/config/environment.rb:5:in `<top (required)>'
    from /home/ritesh/projects/sample_app/spec/spec_helper.rb:3:in `require'
    from /home/ritesh/projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
    from /home/ritesh/projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
    from /home/ritesh/projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
    from /home/ritesh/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

為什么這個語法錯誤即將到來我認為這個代碼行是正確的書面匹配'/ contact':'static_pages #contact'請幫助糾正它。

你之前忘記了逗號to:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM