我有三个表格,帐户、活动和帐户活动。我想在广告系列编辑表单中为选定帐户设置复选框。
我有这样的 Campaign 模型:
class Campaign < ActiveRecord::Base
has_and_belongs_to_many :accounts
accepts_nested_attributes_for :accounts
end
我想我不需要在 Account 上定义关系。
我的表格是:
= hidden_field_tag "campaign[accounts_ids][]", nil
- Account.all.each do |account|
%label.checkbox
= check_box_tag "campaign[accounts_ids][]", account.id, @campaign.account_ids.include?(account.id),
id: dom_id(account)
= "#{account.name} - #{account.email}"
但我收到了这个错误:
unknown attribute: accounts_ids