0

这是我的路由配置,下面我发布了我尝试生成用户模型时收到的错误。我在教程的这一部分中陷入困境,请帮助!如果我不够具体,请收件箱给我,我是这个世界的新手!谢谢,麻烦您了!

SampleApp::Application.routes.draw do
  get "users/new"
  root to: 'static_pages#home

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

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

  # 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)'

它正在显示此错误

unknown00231256eabc:sample_app micahsherman$ rails generate model User name:string      email:string
/Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/activesupport-  3.2.11/lib/active_support/dependencies.rb:245:in `load':     /Users/micahsherman/rails_projects/sample_app/config/routes.rb:5: syntax error, unexpected      tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
  match '/help', to:'static_pages#help'
           ^
/Users/micahsherman/rails_projects/sample_app/config/routes.rb:5: syntax error, unexpected   tIDENTIFIER, expecting keyword_end
  match '/help', to:'static_pages#help'
                             ^
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-   p374@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in    `block in load'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in  `load_dependency'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-  p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:40:in   `block in load_paths'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:40:in `each'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-  p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/file_update_checker.rb:78:in `call'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/file_update_checker.rb:78:in `execute'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/micahsherman/rails_projects/sample_app/config/environment.rb:5:in `<top (required)>'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application.rb:103:in `require'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
    from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p374@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/commands.rb:25:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
4

1 回答 1

4

您在这里缺少一个单引号:

root to: 'static_pages#home
于 2013-02-06T23:36:17.927 回答