[Rails] after_save, after_create, before_save etc... multiple times launching ...bug???

hangonsoft at free.fr hangonsoft at free.fr
Wed Jan 26 17:01:43 GMT 2005


hi,

i have 2 tables (rooms & exams) linked by a intermediate table (has and belongs
to many relation)


when an new exam is created i want it to be validated for every room

so inside exam model file i wrote:

before_create :linkeveryroom

private
def linkeveryroom
    self.rooms<<Room.find_all
end

(or something like that i'm not in front of my Mac)

it seems to work BUT the association is done 3 to 6 times (depends on what i use
after-save or after_create or even with before)...each linking is present
multiple times in the intermediate table (exams_rooms)

someone experiencing the same behaviours???


hangon


More information about the Rails mailing list