This project is archived and is in readonly mode.
Callbacks being called twice with nested attributes
Reported by Fabio Yamate | February 5th, 2010 @ 08:36 PM
With a blog project with post-comments, using rails 2.3.5:
class Post < ActiveRecord::Base
has_many :comments
accepts_nested_attributes_for :comments
...
end
class Comment < ActiveRecord::Base
belongs_to :post
...
end
So, printing out all callbacks:
def callback_name
p "#{callback_name} - #{object_id}"
...
end
each callback of comments is called twice, including save.
"post_before_validation - 2174878780"
"post_before_validation_on_update - 2174878780"
"comment_before_validation - 2174811020"
"comment_before_validation_on_update - 2174811020"
"comment_after_validation - 2174811020"
"comment_after_validation_on_update - 2174811020"
"comment_before_validation - 2174811020"
"comment_before_validation_on_update - 2174811020"
"comment_after_validation - 2174811020"
"comment_after_validation_on_update - 2174811020"
"post_after_validation - 2174878780"
"post_after_validation_on_update - 2174878780"
"post_before_save - 2174878780"
"post_before_update - 2174878780"
"comment_before_save - 2174811020"
"comment_before_update - 2174811020"
"comment_after_update - 2174811020"
"comment_after_save - 2174811020"
"comment_before_save - 2174811020"
"comment_before_update - 2174811020"
"comment_after_update - 2174811020"
"comment_after_save - 2174811020"
"post_after_update - 2174878780"
"post_after_save - 2174878780"
Comments and changes to this ticket
-
José Valim February 6th, 2010 @ 09:43 AM
- State changed from new to resolved
This was already fixed on both master and 2-3-stable branches according to this ticket: #3575. Thanks!
-
José Valim February 6th, 2010 @ 09:43 AM
- State changed from resolved to duplicate
-
Ryan Bigg October 9th, 2010 @ 09:47 PM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>