Sha256: c40379cd8f21e7b72973016deac9e35cd80d210f9c15e4c7a2a9c044fe1a9da4

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

module ActiveAdminAddons
  module RansackFormBuilderExtension
    extend ActiveSupport::Concern

    included do
      alias_method_chain :input, :ransack
    end

    def input_with_ransack(method, options = {})
      if object.is_a?(::Ransack::Search)
        klass = object.klass

        if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[method])
          options[:collection] ||= attr.options
          options[:as] = :select
        end
      end

      input_without_ransack(method, options)
    end
  end
end

::Formtastic::FormBuilder.send :include, ActiveAdminAddons::RansackFormBuilderExtension

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activeadmin_addons-0.10.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.9.3 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.9.2 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.9.1 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.9.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.8.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.7.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb