This project is archived and is in readonly mode.
Update the documentation for association callbacks
Reported by Nathaniel Bibler | May 17th, 2009 @ 05:54 PM | in 3.x
This is a follow-up ticket to discontinue hijacking ticket #2100. See comments starting here.
The documentation around the association callbacks (@after_add@,
after_remove
) is insufficient. It fails to highlight
the that objects may be returned to those callback methods which
are invalid and/or non-persisted. In the current implementation,
you must do something like the following to ensure that you're
working with an object that is actually created and persisted:
class Blog
has_many posts, :after_add => :do_something
def do_something(post)
post.profit! unless post.new_record?
end
end
This is highly unexpected behavior for something described as @after_add@, especially when if you refresh the parent object, the invalid child is non-existent.
I'll attempt a documentation patch to this thread in the coming days.
Comments and changes to this ticket
-
Rohit Arondekar October 9th, 2010 @ 04:16 AM
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
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>
People watching this ticket
Referenced by
- 2100 Change behaviour of association's after_add callback BTW: I apologize to Kenneth for hijacking this ticket. :-...