Sha256: fd3f484a79bb04b0327066fad160a9f75ec3f0d6649c035d43e43a54ef562315

Contents?: true

Size: 768 Bytes

Versions: 53

Compression:

Stored size: 768 Bytes

Contents

module Admin
  class Select2AjaxController < ApplicationController
    before_action(:authenticate_user!) if defined?(Devise)
    before_action { EffectiveResources.authorize!(self, :admin, :effective_resources) }

    include Effective::Select2AjaxController

    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

    private

    def to_select2(user)
      "<span>#{user}</span> <small>#{user.email}</small>"
    end

  end

end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
effective_resources-2.7.15 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.14 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.13 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.12 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.11 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.10 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.9 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.8 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.7 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.6 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.5 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.4 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.3 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.2 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.1 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.7.0 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.6.2 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.6.1 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.6.0 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.5.4 app/controllers/admin/select2_ajax_controller.rb