index.html.erb
<%= form_tag(:controller => 'publishers', :action => 'playlist' ) do %>
<table id='audio_list' >
<thead>
<tr>
<th></th>
<th>Nr </th>
<th>Title</th>
<th></th>
</tr>
</thead>
<tbody>
<% @publishers.each do |publisher| %>
<tr>
Here is my check_box_tag am sending to the controller
<td><%= check_box_tag "publisher_ids[]", publisher.id %></td>
<td><%= publisher.id %></td>
<td><%= publisher.title %></td>
<%= link_to 'Play', publisher ,:remote => true %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br/>
<br/>
<%= submit_tag "Create Playlist" %>
<% end %>
控制器
def playlist
@test_list=Publisher.order('id DESC').find(params[:publisher_ids])
end
现在控制器只从一个页面获取检查值,我想从所有页面获取检查值。
答案 0 :(得分:0)
.find()
返回一个项目,其输入(如果是微不足道的话)被解释为该模型的ID。试试.find_all_by_publisher_id()