0

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>

他のすべては正常に動作します。どんな助けでも大歓迎です!

オリバー

4

2 に答える 2

1

の戻り値を出力しています.each

<%= @samples.each do |sample| %>

する必要があります

<% @samples.each do |sample| %>
于 2013-04-08T15:23:41.963 に答える