在 Michael Hartl 的书中,路线“/static_pages/help”不会显示

From the Michael Hartl book, the route "/static_pages/help" won't show

每当我尝试导航到 this link 时, 它不会更改为此视图。它只是继续显示根路由。

请有人指出我做错了什么。

class StaticPagesController < ApplicationController
  def home
  end

  def help
  end
end


class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
    def hello
    render html: "hello, world!"
    end
end

Rails.application.routes.draw do
  get 'static_pages/home'

  get 'static_pages/help'

  root 'application#hello'
end

尝试指定相关的控制器,完成后没有理由不工作:

Rails.application.routes.draw do
  root 'application#hello'
  get 'static_pages/home', to: 'static_pages#home'
  get 'static_pages/help', to: 'static_pages#help'
end

不知道是不是每个人都这样,不过我觉得还是把root放在上面比较好。