0
class Batch < ActiveRecord::Base
has_many :transaction_groups
has_many :transactions , :through=>:transaction_groups
end
class TransactionGroup < ActiveRecord::Base
attr_accessible :g_id
belongs_to :batch
has_many :transactions, dependent => :destroy
end
class Transaction < ActiveRecord::Base
attr_accessible :reference, :transaction_group_id
belongs_to :transaction_group
end
Это моя модель, и я хочу, чтобы сохранить данные, чтобы Batch, TransactionGroup и сделкиКак сохранять данные через has_many через ассоциацию в рельсах
Как выполнить эту задачу?
batch.transaction_groups.transactions.build(:transaction_group_id => batch.transaction_groups.id) #this gaves me an error