Sha256: 0b1dc1a720156e7bcbc903351e666695cf488feca6e32c993c73cfb92b8b56f8

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

module Formtastic
  module TokenInputDefaultForAssociation
    extend ActiveSupport::Concern
    
    included do
      alias_method_chain :default_input_type, :token_default_for_association
    end
    
    def default_input_type_with_token_default_for_association(method, options = {})
      if @object
        reflection = reflection_for(method)
        if reflection && reflection.klass.respond_to?(:autocomplete_attribute) && reflection.macro == :belongs_to
          return :token
        end
      end
      default_input_type_without_token_default_for_association(method, options)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
activeadmin_associations-0.1.3 lib/formtastic/token_input_default_for_association.rb
aa_associations-0.1.2 lib/formtastic/token_input_default_for_association.rb
aa_associations-0.1.1 lib/formtastic/token_input_default_for_association.rb
aa_associations-0.1.0 lib/formtastic/token_input_default_for_association.rb