Giter Club home page Giter Club logo

administrate-field-nested_has_many's Introduction

Administrate::Field::NestedHasMany

A plugin for nested has_many forms in Administrate.

Compatibility

This gem depends on Administrate APIs that may change over time. For this reason, some versions of this gem will be compatible only with some versions of Administrate.

This is a table of known compatibilities. It is accurate to the best of our knowledge. Please let us know if you detect other incompatibilities:

Versions of this gem should work with these versions of Administrate
prior to v1.3.0 unknown
v1.3.0 up to master (last known: v0.15)
master from v0.15

Usage

Add to your Gemfile:

gem "administrate-field-nested_has_many"

Run:

$ bundle install

Add to your FooDashboard:

ATTRIBUTE_TYPES = {
  bars: Field::NestedHasMany.with_options(skip: :foo),
}

The skip option takes a single symbol or list of symbols. It will prevent the nested form from displaying the fields for those attributes.

If a Customer has_many :orders, and you want to render orders as a nested form on the customer edit page, then it is generally necessary to add skip: :customer to the options for the NestedHasMany field. Otherwise, Administrate will try to render a field for the order's :customer attribute, which breaks the nested form logic.

Troubleshooting

undefined method 'new_record?' for nil:NilClass

This field assumes that your models are setup for nested assignment as per Rails conventions. For example, if you have a Recipe that has_many :ingredients, you would have something like this:

class Recipe < ApplicationRecord
  has_many :ingredients

  accepts_nested_attributes_for(
    :ingredients,
    reject_if: :all_blank,
    allow_destroy: true
  )
end

Specifically, you'll see this new_record? error if you forget the accepts_nested_attributes_for declaration.

administrate-field-nested_has_many's People

Contributors

nickcharlton avatar pablobm avatar baldursson avatar c-lliope avatar sedubois avatar badosu avatar 0urobor0s avatar mrjonesbot avatar okuramasafumi avatar ruff9 avatar wkirby avatar thedarkside avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.