Rails プロジェクトをセットアップしました: User->Project->Sample
プロジェクトをテーブルとして表示すると、すべて問題ありません。テーブル テンプレートをレンダリングします。
<%= 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>
他のすべては正常に動作します。どんな助けでも大歓迎です!
オリバー