Docs: Example should append to ignored_columns #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updating the documentation for setting
self.ignored_columnson an ActiveRecord model to append to the existing value instead of overwriting the existing array.Appending to the existing value,
+=, is helpful for the scenario when 2 developers setignored_columnsin different parts of the file and the second one overwrites the first one.Summary
Our team just hit a production issue where two developers set
self.ignored_columnson the same ActiveRecord model, but they did it in different locations in the file. The code looked like this:So the end result was:
This PR updates the example documentation so that it is more likely developers would write this:
which would result in:
Other Information
There is a rubocop rails style code that recommends the "append" pattern for ignored_columns, but this is a style guide which a rails developer might not know about and/or read.
I will look into adding this to
rubocop-railsas well, but that is an optional linter which doesn't have 100% adoption and a documentation fix seems simple enough that everyone can benefit from it.