2010-08-10 38 views
0

我正在爲我的大學開發一個網站,並且遇到了問題。關於Ruby on Rails複選框的問題

有一個頁面,我有大學所有學生的名單。管理員可以選擇一些能夠進行選擇性過程的學生,然後他必須在其他單獨的頁面中看到他們。

我該如何使用Ruby On Rails來做到這一點?

感謝,

雨果亨利

回答

1

你好如果你想使用您應將形式類似於<td><%= check_box_tag "user_ids[]", "#{user.id}", true%><%= user.name%></td>,那麼你會得到陣列OD用戶ID的東西作爲params[:user_ids]裏面寫的複選框,你可能只顯示該其他頁面上的用戶

0
<h1>in your view </h1> 

By checking those ones using checkboxes you can get the id's of those students like this 
<%= check_box_tag "user_ids[]", "#{user.id}", true%> 

通過這些ID的到相應的控制器動作

@users = User.where(:id => params[:user_ids]) 

Display those object details in to the required webpage using @users.each 
<% @users.each do |user| %> 
    <%= user.name %> 
<%end%>