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