Class: Effective::EventRegistrantsSelect2AjaxController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::EventRegistrantsSelect2AjaxController
- Includes:
- Select2AjaxController
- Defined in:
- app/controllers/effective/event_registrants_select2_ajax_controller.rb
Instance Method Summary collapse
Instance Method Details
#organizations ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/effective/event_registrants_select2_ajax_controller.rb', line 32 def organizations raise('expected EffectiveEvents.organization_enabled?') unless EffectiveEvents.organization_enabled? klass = EffectiveMemberships.Organization raise('an EffectiveMemberships.Organization is required') unless klass.try(:effective_memberships_organization?) collection = klass.all # Authorize EffectiveResources.(self, :member_organizations, collection.klass) respond_with_select2_ajax(collection, skip_authorize: true) do |organization| { id: organization.to_param, text: organization.to_s } end end |
#users ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/effective/event_registrants_select2_ajax_controller.rb', line 7 def users :users, Effective::EventRegistrant with_organizations = current_user.class.try(:effective_memberships_organization_user?) collection = current_user.class.all collection = collection.includes(:organizations) if with_organizations respond_with_select2_ajax(collection, skip_authorize: true) do |user| data = { first_name: user.first_name, last_name: user.last_name, email: user.email } if with_organizations data[:company] = user.organizations.first.try(:to_s) data[:organization_id] = user.organizations.first.try(:id) data[:organization_type] = user.organizations.first.try(:class).try(:name) end { id: user.to_param, text: to_select2(user, with_organizations), data: data } end end |