Skip to content
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

Fix for HABTM associations when updated within 1 transaction #812

Closed
wants to merge 1 commit into from

Conversation

samboylett
Copy link
Contributor

When updating 2 models with a HABTM association, and using
accepts_nested_attributes_for, the association was using the
version ID instead of the transaction ID to reference the change.
This was braking the association logic and preventing proper
reification.

@@ -526,7 +526,7 @@ def save_associations_has_and_belongs_to_many(version)
self.class.paper_trail_save_join_tables.include?(a.name) ||
a.klass.paper_trail_enabled_for_model?
assoc_version_args = {
version_id: version.id,
version_id: version.transaction_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me again why we store transaction_id in the version_id column? Is it because there is no "through" table in a HABTM?

@jaredbeck
Copy link
Member

This looks good, thanks Sam. Please add a changelog entry.

When updating 2 models with a HABTM association, and using
accepts_nested_attributes_for, the association was using the
version ID instead of the transaction ID to reference the change.
This was braking the association logic and preventing proper
reification.
@jaredbeck
Copy link
Member

Thanks, Sam! Merged offline as 4ad6254 with tiny fix to changelog.

@jaredbeck jaredbeck closed this May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants