Skip to content

Instantly share code, notes, and snippets.

@aamax
Created September 12, 2013 19:52
Show Gist options
  • Save aamax/6542920 to your computer and use it in GitHub Desktop.
Save aamax/6542920 to your computer and use it in GitHub Desktop.
def edit
@publication = Publication.find(params[:id])
@recipients = @publication.users
@users = User.first
end
<%= f.label :recipients %>
<select id='recipients_id' multiple='multiple' name='recipients[id][]'>
<% User.all.each do |u| %>
<option value='<%= u.id %>'
<%= @recipients.include?(u) ? "selected='selected'" : '' %> ><%= u.name %></option>
<% end %>
</select>
<%= collection_select(:users, :id, User.all, :id, :name, options ={}, {multiple: true}) %>
<%= select(:auser, 'userrec', User.all.map {|u| [u.name, u.id]}, {:selected => @recipients}, {multiple: true}) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment