Ruby on Rails
Friday, July 7, 2017
I have a model called Dataset which registers an after_save callback to do some work when its name attribute has changed. This callback is manipulating a DatasetLink model but the association between the two is through another model called Attribute.
The scenario I'm hoping to come to an explanation for is this:
Within the after_save callback, the immediate reference to the Dataset model that's changing returns true for name_changed? and changed?. However, when traversing the association to a DatasetLink record, the link's reference to the dataset has the new value for the name but it doesn't register the dataset as being changed nor the name being changed. It just has the new name.
I'm on Rails 3.0.20. I'm wondering if this is the expected behavior or not. I've specified the inverse_of argument on as many associations as I could have.
-- The scenario I'm hoping to come to an explanation for is this:
Within the after_save callback, the immediate reference to the Dataset model that's changing returns true for name_changed? and changed?. However, when traversing the association to a DatasetLink record, the link's reference to the dataset has the new value for the name but it doesn't register the dataset as being changed nor the name being changed. It just has the new name.
I'm on Rails 3.0.20. I'm wondering if this is the expected behavior or not. I've specified the inverse_of argument on as many associations as I could have.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a4ba8648-9d82-4235-b4ed-7fe48d2a590e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment