Rails 中未定义的局部变量或方法“welcome_goodbye_path”?

undefined local variable or method `welcome_goodbye_path' in Rails?

我是 rails 的初学者,正在尝试学习使用 "Agile Web Development using Rails"。我想创建一个 link 到 webpage.This 是我的代码:

<h1>Hello, Rails!</h1>
<p>
It is now <%= Time.now %>
</p>
<p>
Time to say
<%= link_to "Goodbye", welcome_goodbye_path %>!
</p>

但这给出了错误...

undefined local variable or method `welcome_goodbye_path' 

我做错了什么? 这是我的欢迎控制器的代码:

class WelcomeController < ApplicationController
  def index
  end
  def goodbye
  end
end

这是佣金路线的结果:

        Prefix Verb   URI Pattern                  Controller#Action
     articles GET    /articles(.:format)          articles#index
              POST   /articles(.:format)          articles#create
  new_article GET    /articles/new(.:format)      articles#new
 edit_article GET    /articles/:id/edit(.:format) articles#edit
      article GET    /articles/:id(.:format)      articles#show
              PATCH  /articles/:id(.:format)      articles#update
              PUT    /articles/:id(.:format)      articles#update
              DELETE /articles/:id(.:format)      articles#destroy
welcome_index GET    /welcome(.:format)           welcome#index
              POST   /welcome(.:format)           welcome#create
  new_welcome GET    /welcome/new(.:format)       welcome#new
 edit_welcome GET    /welcome/:id/edit(.:format)  welcome#edit
      welcome GET    /welcome/:id(.:format)       welcome#show
              PATCH  /welcome/:id(.:format)       welcome#update
              PUT    /welcome/:id(.:format)       welcome#update
              DELETE /welcome/:id(.:format)       welcome#destroy
         root GET    /   

您必须显示 config/routes.rb。你需要这样的东西:

get 'goodbye', to: 'welcome#goodbye', as: 'welcome_goodbye'