Sha256: aad191a477aca0def89f1aed990cb54f73e6de691800f886339e2c02dc27c95c

Contents?: true

Size: 639 Bytes

Versions: 21

Compression:

Stored size: 639 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

21 entries across 21 versions & 1 rubygems

Version Path
activeadmin_addons-0.6.4 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.6.3 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.6.2 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.6.1 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.6.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.5.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.4.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.3.4 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.3.3 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.3.2 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.3.1 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.3.0 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.8 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.7 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.6 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.5 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.4 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.3 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.2 lib/activeadmin_addons/support/enumerize_formtastic_support.rb
activeadmin_addons-0.2.1 lib/activeadmin_addons/support/enumerize_formtastic_support.rb