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.5.3 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.5.2 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.5.1 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.5.0 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.7 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.6 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.5 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.4 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.3 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.2 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.1 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.4.0 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.3.0 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.12 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.11 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.10 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.9 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.8 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.7 app/controllers/admin/select2_ajax_controller.rb
effective_resources-2.2.6 app/controllers/admin/select2_ajax_controller.rb