0
has_many belongs_toリレーションを持つモデル製品とギャラリーがあります。ネストされたアトリビュート機能を実装しています。問題は次のとおりです。ギャラリーを追加すると、ギャラリーが2つ追加されます(下の図を参照)。Activeadminネストされた属性
CODE
form do |f|
f.inputs "Product" do
f.input :title, :required => true
f.input :description
f.input :price
f.input :display_image
f .input :product_detail, :hint => "Upload PDF file"
f.input :category
end
f.inputs 'Product Gallery' do
f.has_many :galleries, allow_destroy: true, new_record: 'Add Gallery' do |c|
c.input :image, :hint => c.template.image_tag(c.object.image.url(:thumb))
end
end
f.inputs 'Product Specification' do
f.has_many :specifications, allow_destroy: true, new_record: true do |c|
c.input :specification_label
c.input :specification_details
end
end
f.actions
end
私はこの上の助けが必要。私はこれを解決することができません!!、どんな助けも認められるでしょう。
私はあなたのコードを見ることができませんが、前に同じことに遭遇しました。f.fields_forの外にあるフィールドを追加するリンク/ボタンを置く必要があります:ギャラリー –
こんにちは@ aldrien.h返信ありがとう、私私のコードでどこでもf.fields_forを使用していないので、私は自分の質問を編集し、コードを追加しました! – Pbms
私はあなたが2つのループを持っていると思います。そのため、2回生成します。 –