Last active
January 8, 2016 17:34
-
-
Save a-leung/4b9df65ed98f82e1baac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_many model_B | |
before_save set_model_b_attributes | |
def set_model_b_attributes | |
self.bs.each do |b| | |
b.value = self.value | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
belongs_to model_A, inverse_of: model_B |
Got this working! (model_a
setting model_b.attribute
)
I think I was trying to write to model_b
too late in the whole save process (or after model_b
validated and basically frozen for changes).
Thanks for working through this with me. It definitely helped to know that this was not 'impossible' to do.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I will try that. The app has a lot more going on so I will try a few things in a fresh project instead first.