John Merlino <stoicism1@...> writes: > > 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 >
How can you update a record with the id when the id doesn't exist yet? You can't. However, you might try changing your call to after_create rather than before_create. Mind you, this seems like replication of the id field anyway, so what's the point? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.