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

Only swap changed attributes which are persistable, i.e. are DB columns. #152

Merged
merged 2 commits into from
Jul 6, 2015

Conversation

ludwigschubert
Copy link
Contributor

This patches an issue where acts_as_list would try to swap virtual attributes, resulting in a crashing ActiveRecord write_attribute method.

I observed this issue in combination with acts_as_taggable, I have attached a partial stack trace here.
My solution built on a similar fix for the paper_trail gem, from this PR.

This fixes an issue where acts_as_list would try to swap virtual attributes, resulting in a crashing ActiveRecord's write_attribute method.
@ludwigschubert
Copy link
Contributor Author

@swanandp I'd still like to see this merged.
Is there anything I can do to make this easier for you? Would you like me to add a test for a specific case?

The use of select didn't break functionality, but was confusing.
self[k], @changed_attributes[k] }
@changed_attributes.each do |k, _|
if self.class.column_names.include? k
@changed_attributes[k], self[k] = self[k], @changed_attributes[k]

Choose a reason for hiding this comment

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

Line is too long. [81/80]

@swanandp
Copy link
Contributor

swanandp commented Jul 6, 2015

Looks good to me.

swanandp added a commit that referenced this pull request Jul 6, 2015
Only swap changed attributes which are persistable, i.e. are DB columns.
@swanandp swanandp merged commit bd87a59 into brendon:master Jul 6, 2015
@ludwigschubert
Copy link
Contributor Author

@swanandp thank you!

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.

3 participants