Class: Admin::Select2AjaxController

Inherits:
ApplicationController
  • Object
show all
Includes:
Effective::Select2AjaxController
Defined in:
app/controllers/admin/select2_ajax_controller.rb

Instance Method Summary collapse

Methods included from Effective::Select2AjaxController

#respond_with_select2_ajax

Instance Method Details

#organizationsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/select2_ajax_controller.rb', line 16

def organizations
  raise('the effective memberships gem is required') unless defined?(EffectiveMemberships)

  klass = EffectiveMemberships.Organization
  raise('an EffectiveMemberships.Organization is required') unless klass.try(:effective_memberships_organization?)

  collection = klass.all

  respond_with_select2_ajax(collection) do |organization|
    { id: organization.to_param, text: organization.try(:to_select2) || to_select2(organization) }
  end
end

#usersObject



8
9
10
11
12
13
14
# File 'app/controllers/admin/select2_ajax_controller.rb', line 8

def users
  collection = current_user.class.all

  respond_with_select2_ajax(collection) do |user|
    { id: user.to_param, text: user.try(:to_select2) || to_select2(user) }
  end
end