Sha256: bc1422b77b103862a77a1f4d7436b9efc41598c8842dcd6892c7e0ba793753b8

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

require 'rails_admin/config/fields/association'

module RailsAdmin
  module Config
    module Fields
      module Types
        class HasManyAssociation < RailsAdmin::Config::Fields::Association
          # Register field type for the type loader
          RailsAdmin::Config::Fields::Types::register(self)

          register_instance_option :partial do
            nested_form ? :form_nested_many : :form_filtering_multiselect
          end

          # orderable associated objects
          register_instance_option :orderable do
            false
          end

          register_instance_option :inline_add do
            true
          end

          def method_name
            nested_form ? "#{super}_attributes".to_sym : "#{super.to_s.singularize}_ids".to_sym  # name_ids
          end

          # Reader for validation errors of the bound object
          def errors
            bindings[:object].errors[name]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_admin-0.6.0 lib/rails_admin/config/fields/types/has_many_association.rb
rails_admin-0.5.0 lib/rails_admin/config/fields/types/has_many_association.rb
rails_admin-0.4.9 lib/rails_admin/config/fields/types/has_many_association.rb
rails_admin-0.4.8 lib/rails_admin/config/fields/types/has_many_association.rb
rails_admin-0.4.7 lib/rails_admin/config/fields/types/has_many_association.rb