search for: add_sequence

Displaying 1 result from an estimated 1 matches for "add_sequence".

2011 Jun 27
2
insert value of primary key into another field before record is saved
...assign it to another field of the same record called ''sequence''. So if the primary key of the record is 23, then the sequence should also be 23. But the record is not created yet, so it doesnt have an id yet. I tried doing this in subbook model: belongs_to :book before_create :add_sequence def add_sequence self.sequence = self.id end But that didn''t do anything at all when running the seed task. Any idea how to update another field with id of record before that record is saved to database? Thanks for response -- You received this message because you are subscri...