Class: Admin::Select2AjaxController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::Select2AjaxController
show all
- Includes:
- Effective::Select2AjaxController
- Defined in:
- app/controllers/admin/select2_ajax_controller.rb
Instance Method Summary
collapse
#respond_with_select2_ajax
Instance Method Details
#organizations ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/admin/select2_ajax_controller.rb', line 22
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
if collection.respond_to?(:to_select2)
collection = collection.to_select2
elsif collection.respond_to?(:sorted)
collection = collection.sorted
end
respond_with_select2_ajax(collection) do |organization|
{ id: organization.to_param, text: organization.try(:to_select2) || to_select2(organization) }
end
end
|
#users ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/admin/select2_ajax_controller.rb', line 8
def users
collection = current_user.class.all
if collection.respond_to?(:to_select2)
collection = collection.to_select2
elsif collection.respond_to?(:sorted)
collection = collection.sorted
end
respond_with_select2_ajax(collection) do |user|
{ id: user.to_param, text: user.try(:to_select2) || to_select2(user) }
end
end
|