まず、私は Rails 4 と activeadmin rails 4 ブランチで作業していることに注意してください。https://github.com/gregbell/active_admin/tree/rails4
私は多形性である2つのモデルの写真を持っています
class Picture < ActiveRecord::Base
belongs_to :picture_category
belongs_to :imageable, polymorphic: true
mount_uploader :image, ImageUploader
end
そして船
class Ship < ActiveRecord::Base
has_many :pictures, as: :imageable
accepts_nested_attributes_for :pictures
end
そしてactiveadmin ship.rb
ActiveAdmin.register Ship do
form do |f|
f.inputs do
f.inputs
f.has_many :pictures, :sortable => :picture_categories do |ff|
ff.input :name
end
end
f.actions
end
controller do
def permitted_params
params.permit(:ship => [:name, :title, :short_desc, :description, :position, :pictures, :enabled, :ship_provider_id, :picture_category_id, :picture_id])
end
end
end
しかし、結果は次のとおりです。
- 削除ボタンを削除して送信するにはどうすればよいですか
- このフォームを表示および編集フォームでのみ表示するにはどうすればよいですか?
コードの間違いを指摘してください。