我正在为我的大学开发一个网站,并且遇到了问题。关于Ruby on Rails复选框的问题
有一个页面,我有大学所有学生的名单。管理员可以选择一些能够进行选择性过程的学生,然后他必须在其他单独的页面中看到他们。
我该如何使用Ruby On Rails来做到这一点?
感谢,
雨果亨利
我正在为我的大学开发一个网站,并且遇到了问题。关于Ruby on Rails复选框的问题
有一个页面,我有大学所有学生的名单。管理员可以选择一些能够进行选择性过程的学生,然后他必须在其他单独的页面中看到他们。
我该如何使用Ruby On Rails来做到这一点?
感谢,
雨果亨利
你好如果你想使用您应将形式类似于<td><%= check_box_tag "user_ids[]", "#{user.id}", true%><%= user.name%></td>
,那么你会得到阵列OD用户ID的东西作为params[:user_ids]
里面写的复选框,你可能只显示该其他页面上的用户
<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%>