activerecord-import gem: has_many through issue

511 views Asked by At

With help of activerecord-import gem I'm trying to save list of records with has_many through children in one query.

my models:

class Mailing < ActiveRecord::Base

  has_many :mailing_modifications
  has_many :modifications, through: :mailing_modifications

end

class Modification < ActiveRecord::Base

  has_many :mailing_modifications, dependent: :destroy
  has_many :mailings, through: :mailing_modifications

end

class MailingModification < ActiveRecord::Base

  belongs_to :mailing
  belongs_to :modification

end

My code for saving:

mailing = Mailing.new
mailing.modifications.build
mailings << mailing
Mailing.import(mailings, recursive: true)

But I'm get an error NoMethodError: undefined method modification_id=' for #<Modification:0x00000006eb01d0>

0

There are 0 answers