diff --git a/app/models/user.rb b/app/models/user.rb index 576bf938..cda66cbb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -195,6 +195,12 @@ def mature? general_member? && application.processed_at.present? && application.processed_at <= 14.days.ago end + class << self + def all_members_for_dropdown + User.all_members.order(name: :asc).collect { |u| ["#{u.name} (#{u.email})", u.id] } + end + end + private def gravatar_email diff --git a/app/views/admin/door_codes/_form.html.erb b/app/views/admin/door_codes/_form.html.erb index d67d38f7..31bf3958 100644 --- a/app/views/admin/door_codes/_form.html.erb +++ b/app/views/admin/door_codes/_form.html.erb @@ -18,7 +18,7 @@
<%= door_code_form.label :user_id %> - <%= door_code_form.select :user_id, User.all.collect { |u| [u.name, u.id] }, { include_blank: true} %> + <%= door_code_form.select :user_id, User.all_members_for_dropdown, { include_blank: true} %>

Optional. Use only if you want to assign this code to an existing user.