-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[back_assignments] create fixture models and spec titles #190
base: master
Are you sure you want to change the base?
Conversation
- unset belongs_to when setting origin to nil - set/unset collection_of
model.base.rb to be able to define a after_save for dirty associations.
- do not call save more than once - propagate save for collection_of associations
b97403b
to
12b54be
Compare
… into back_assignments Conflicts: spec/fixtures/models/parent.rb spec/unit/assocations_dual_spec.rb
reverse_association is specified.
Hi! Thanks for submitting this. I can see the benefits, but I can see a fundamental flaw in the implementation. Given that CouchDB does not support transactions, you are opening the floodgates to data inconsistencies by attempting to auto-save the other documents. In my opinion, all CouchRest Model operations should be atomic, and not have cascading callbacks in order to maintain predictability. However, I like your refactoring of the "association" parts. If you'd like to submit a pull request with a set of changes to the association handling so that you can turn your changes into another gem, more than happy to add them. A gem called something like |
when two models are referencing each other as associations, affecting one model association attribute will also assign the corresponding attribute in the referenced model. Saving a model will trigger save of associated models.
This reproduce the effect of
ActiveRecord
on relationel databases.belongs_to
andas_many
rely on the same foreign key.*example:
without back assignments:
with back assignments:
reverse association calculation
back assignment is triggered by the presence of the
:reverse_association
option.