我的原始数据,我设置Rails项目: 用户 - >项目 - >样品Rails的呈现在HTML
当我认为我的项目如表,一切都很好。我渲染表模板:
<%= render 'layouts/projects_table' %>
但是当我使我的样本项目
<%= render 'layouts/samples_table' %>
我得到的表,但表之前,我得到我的原始数据呈现:
[#<Sample id: 28, name: "abcd", size: 11, quantity: 11.0, created_at: "2013-04-04 09:58:50"> ... ]
项目控制器:
def show
@project = Project.find(params[:id])
@samples = @project.samples
end
_samples_table:
<table id="samples" class="display">
<thead>
<tr>
<th>
Sample Name
</th>
<th>
Size
</th>
<th>
Quantity
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<%= @samples.each do |sample| %>
<tr>
<td>
<%= link_to sample.name, project_sample_path(@project, sample) %>
</td>
<td>
<%= sample.size %>
</td>
<td>
<%= sample.quantity %>
</td>
<td>
<% if !sample.libraries.any?%>
<%= link_to 'Del', project_sample_path(@project, sample),
:confirm => 'Are you sure?', :method => :delete %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
其他一切工作正常。 任何帮助,将不胜感激!
奥利弗
您需要向我们展示你的'samples_table'视图的代码。 – jdl 2013-04-08 15:17:16