您好我有两个名为Search_result和sharing_type的模型。我在两个模型之间使用了has_many关联。 在我的search_result.rb
中class SearchResult < ActiveRecord::Base
has_many :sharing_types ,dependent: :destroy
accepts_nested_attributes_for :sharing_types, allow_destroy: true
end
在我的sharing_type.rb中我定义为
class SharingType < ActiveRecord::Base
belongs_to :search_result
end
在我的ActiveAdmin中
ActiveAdmin.register SearchResult do
permit_params:gender,:postdate:location_cd,:location_name,
sharing_types_attributes: [:id, :typename ]
form multipart: true do |f|
f.input :gender
f.input :postdate, :required => false
f.input :location_cd, :required => false, :label => "Location Code"
f.input :location_name, :required => false, :label => "Location Name"
f.inputs "sharing_types" do
f.has_many :sharing_types, allow_destroy: true do |cf|
cf.input :typename
end
end
f.actions
end
end
在我的活动管理视图中,没有显示typename的输入字段。