Skip to content

Simple Has Many Field Type (Association)

Aiman Najjar edited this page Mar 18, 2016 · 1 revision

RailsAdminSimpleHasMany

RailsAdminSimpleHasMany is a field type for Rails Admin for has_many associations that do not require a complex multiselect field. RailsAdminSimpleHasMany has been only tested with Mongoid adapter and on Chrome/Safari. I do not expect major issues with other ORMs or browsers, but bugs and enhancements pull requests are welcome!

Example of how the collection field would look like:

RailsAdminSimpleHasMany screenshot1

Usage

Simply add the following gem to your Gemfile:

gem "rails_admin_simple_has_many"

And then run bundle (note: rails_admin should already be in your Gemfile)

Next, add the field as follows in your model

rails_admin do
    field :players, :simple_has_many do
        help 'Please add 12 players'
        orderable true
        required true
    end
end

Note: orderable enables UI controls to move items up and down but you still need to support it in your models, see here for an example using a similar widget.

Clone this wiki locally