Hi, I have a form, that after submit saves data in 2 different tables.
It works fine, only in the member-table there is an extra record added,
each time the user submits data, with in the rubric_idfield NULL. I
checked the parsed data, and they are fine, no extra anything. Should
be simple but I cannot pinpoint it. Please, if you could spare some
time…
Code:
Action =
Combination.transaction do @members.combination = @combination @combination.add_rubrics(@rubrics) @combination.save @members.save
end
add_rubrics =
def add_rubrics(rubrics)
rubrics.items.each do |item|
li = Member.new_rubric(item)
members << li
end
end
new_rubric(item)=
def self.new_rubric(item)
li = self.new
li.rubric_id = item.id
li
end
I’m convinced it has to be here, but I don’t know why it happens.
Yep.
Iknow there must be a season for this extra record, and it’s the first
I’ve ever seen this. I even restarted my working sytem a few times (Mac
OSX 4.8; MAMP, Locomotive, Textmate), with no difference. That’s why
I’m so… flabbergasted. (Like that word)
Hi Fred, thanks for replying. Unjfortunately, I don’t think that is the
case. The rubrics all come from a predefined list, so there is no
saving involved before @rubrics is created. That is what makes is so
wierd for me.
Frederick C. schreef:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.