# all the users that are NOT members of this group
def available_users
- User.all - users
+ User.find(:all, :order => 'name') - users
end
def set_users(new_users=[])
self.users.clear
- new_users=(new_users || []).compact.uniq
+ new_users=(new_users||[]).compact.uniq
self.users = User.find(new_users)
save
end
<td style="padding: 5px 0pt;" valign="top">
<h2>Non-members</h2>
<select name="from" id="from" size="10" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% @group.available_users.each do |user| %>
+ <% @group.available_users.sort.each do |user| %>
<option value="<%= user.id -%>"><%= user.login %></option>
<% end %>
</select>
<h2>Members</h2>
<select name="users[]" id="to" size="10" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
- <%= options_from_collection_for_select(@group.users, "id", "login") %>
+ <%= options_from_collection_for_select(@group.users.sort, "id", "login") %>
</select><br>
<div style="padding: 5px 0pt;">