Routing Error during “Ruby on Rails-Tutorial”

后端 未结 9 1984
忘了有多久
忘了有多久 2021-01-24 03:25

It seems like some people here had this problem but I couldn\'t find any solution in another topic.

I am doing Chapter 3 of the Ruby on Rails-Tutorial, working on the sta

相关标签:
9条回答
  • 2021-01-24 03:50

    your routes.rb file has problems, use either RESTful style:

    resource :static_pages do 
      collection do 
        get :home
        get :help
        get :about
      end 
    end
    

    or the non RESTful style:

    match "static_pages/home", :controller => "static_pages", :action => "home"
    match "static_pages/help", :controller => "static_pages", :action => "help"
    match "static_pages/about", :controller => "static_pages", :action => "about"
    

    for more details please refer to official guide: http://guides.rubyonrails.org/routing.html

    0 讨论(0)
  • 2021-01-24 03:50

    In

    config/routes.rb

    uncomment

    root :to => 'welcome#index'

    0 讨论(0)
  • 2021-01-24 03:53

    If you are using Spork you must re-run Spork so your tests will consider the changes in config files like routes.rb, that are pre-loaded with Spork, so are not automatically updated.

    1. Stop Spork (Ctrl + C)
    2. Run Spork again (bundle exec spork)

    Source: this is the source of this information "after changing a file included in the prefork loading (such as routes.rb), you will have to restart the Spork server to load the new Rails environment. If your tests are failing when you think they should be passing, quit the Spork server with Control-C and restart it

    0 讨论(0)
  • 2021-01-24 03:55

    From Ruby 2 to Ruby 3 there are some differences, but still the documentation for 3 is not easy to be found. There should be a tutorial only for that: practical differences between rails 2 and 3. The guide provided by downloading Ruby on rails is "The book of ruby" but it's not good anymore. It should at least contain an advice at the beginning of chapter 19.

    0 讨论(0)
  • 2021-01-24 04:01

    I had a few problems working through the Rails Tutorial, and it helped to be able to consult the author's GitHub repo: https://github.com/railstutorial

    Find the file you're working on and compare it line by line. Or just cut and paste the full file and see if it will run, then track down your error.

    0 讨论(0)
  • 2021-01-24 04:04

    If you check the routes.rb in config you'll probably find that the there is a 'e' missing from /home. Add that and you are golden. Or green. Or whatever :)

    0 讨论(0)
提交回复
热议问题