rubocop-rails
rubocop-rails copied to clipboard
Allow model associations to reference class_name: self.name
When used in concern mixins, the class name that the association is included in may be declared dynamically, instead of a static string.
This now only verifies that the class_name: option is not referencing a
constant, so other (dynamic) means of passing a string to the association
reflection can be supported.
Before submitting the PR make sure the following are checked:
- [x] Wrote good commit messages.
- [x] Commit message starts with
[Fix #issue-number](if the related issue exists). - [x] Feature branch is up-to-date with
master(if not - rebase it). - [x] Squashed related commits together.
- [x] Added tests.
- [ ] Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
- [x] The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
- [x] Run
bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.
Migrated from rubocop-hq/rubocop#6862
@avit Ping
Another thought: is this cop even needed anymore? I believe it should be deleted instead.
Rails now validates that the option sent to class_name is a string so it seems redundant to also check it with Rubocop.
is this cop even needed anymore? Rails now validates that the option sent to class_name is a string
In what version Rails has introduced this check? We support Rails 4.2+.