Skip to content

Instantly share code, notes, and snippets.

@andrewhl
Created December 11, 2011 15:48
Show Gist options
  • Save andrewhl/1461216 to your computer and use it in GitHub Desktop.
Save andrewhl/1461216 to your computer and use it in GitHub Desktop.
<%= form_tag('/update', :method => "post") %>
<%= select_tag "kgs_names", options_from_collection_for_select(@user, "kgs_names", "kgs_names"), :multiple => true, :class => "kgs_names" %>
<%= select_tag "division", options_for_select(["Alpha", "Beta I", "Beta II", "Gamma I", "Gamma II", "Gamma III", "Gamma IV", "Delta"]), :class => "division" %>
<br />
<%= submit_tag "Submit" %><br/>
<table style="width:400px">
<% @user.each do |item| %>
<tr>
<td><%= item.kgs_names %>
</td>
<td>
<%= item.division %>
</td>
</tr>
<% end %>
</table>
def update
@user = User.all
new_division = params[:division]
kgs_names = params[:kgs_names]
for x in kgs_names
user = User.where(:kgs_names => x)
user.each do |y|
y.division = new_division
y.save
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment