🖥

Rails: ActiveAdmin minimal configuration for creating has_many forms (

2019/04/16に公開

Assumption: The required migration is performed.

Parent model

Specify " accepts nested attributes for" with " has many" .

 class Book < ActiveRecord::Base has_many :images accepts_nested_attributes_for :images end 

Child model

Just make a model.

 class Image < ActiveRecord::Base end 

resource

Point : Specify attributes in permit_params.

 ActiveAdmin.register Book do permit_params :title, images_attributes: [:kind] form do |f| f.inputs do f.input :title end f.inputs do f.has_many :images do |t| t.input :kind end end f.actions end end 

environment

  • ActiveAdmin 1.0.0.pre1
  • Rails 4.0.13
  • ruby 2.0.0

reference

Original by

Rails: ActiveAdmin で has_many なフォーム ( nested resouces ) を作るための最小構成

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion