【发布时间】:2015-06-19 01:47:03
【问题描述】:
我是 Rails 的初学者,正在尝试学习“使用 Rails 进行敏捷 Web 开发”。我想创建一个网页链接。这是我的代码:
<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
这是 rake 路由的结果:
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 /
【问题讨论】:
标签: ruby-on-rails ruby hyperlink error-handling