thanks for response after_create didn't work either.
And even when I call save to trigger the callback:
@subbook = Subbook.create!(defaults.merge(options))
@subbook.save
It still didn't work.
On Jun 27, 1:24 am, Andrew Skegg <andrewsk...@me.com> wrote:
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment