【发布时间】:2014-01-08 19:17:45
【问题描述】:
铁路 4.0.2 红宝石 2.0 mysql 网砖
我的控制器代码是
class ContactController < ApplicationController
def index
@contacts = Contact.find(:all)
end
def show
end
def new
end
def create
end
def update
end
end
在 routes.rb 文件中我放了
resources :contact
我将 index.html.erb 文件放在 app/views/contact 文件夹中,index.html.rb 文件的代码如下
<h1>My Contact List</h1>
<% if @contacts.blank? %>
<p>No contacts to display.</p>
<% else %>
<ul id=”contacts”>
<% @contacts.each do |c| %>
<li>
<%= link_to c.first_name+’ ‘+c.last_name,
{:action => ‘show’, :id => c.id} -%>
</li>
<% end %>
</ul>
<% end %>
即使 webrick 服务器运行良好,但我收到模板丢失错误。但是模板是存在的。任何建议。我是 ROR 的新手。 谢谢
【问题讨论】:
-
为什么你的扩展名是
.html.rb而不是.html.erb? -
对不起,这是拼写错误。文件扩展名为 .html.erb
标签: ruby-on-rails