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

Rails/InverseOf should allow explicit inverse_of: nil #5426

Closed
johnnyshields opened this issue Jan 9, 2018 · 2 comments
Closed

Rails/InverseOf should allow explicit inverse_of: nil #5426

johnnyshields opened this issue Jan 9, 2018 · 2 comments

Comments

@johnnyshields
Copy link

Using Rubocop 0.52. This should be accepted by the cop:

  belongs_to :my_post, class_name: 'Post', inverse_of: nil
@wata727
Copy link
Contributor

wata727 commented Jan 10, 2018

This seems to be correct. As a workaround, you can opt-out by specifying inverse_of: false.

@johnnyshields
Copy link
Author

Thank you!

wata727 added a commit to wata727/rubocop that referenced this issue Jan 11, 2018
… opt-out.

Fixes rubocop#5426

`inverse_of: nil` is a natural way to opt-out.
bbatsov pushed a commit that referenced this issue Jan 13, 2018
#5430)

Fixes #5426

`inverse_of: nil` is a natural way to opt-out.
bdewater added a commit to bdewater/rubocop that referenced this issue Apr 7, 2018
… nil` to opt-out (rubocop#5430)"

This partially reverts commit b12978c.

ActiveRecord specifically checks for `false`, not a falsey value, to stop evaluating if the inverse can be found automatically: https://github.com/rails/rails/blob/d35875b7a3f559155a9378cbe9203b0b8ea580f9/activerecord/lib/active_record/reflection.rb#L647-L652
bbatsov pushed a commit that referenced this issue Apr 11, 2018
…o opt-out (#5430)"

This partially reverts commit b12978c.

ActiveRecord specifically checks for `false`, not a falsey value, to stop evaluating if the inverse can be found automatically: https://github.com/rails/rails/blob/d35875b7a3f559155a9378cbe9203b0b8ea580f9/activerecord/lib/active_record/reflection.rb#L647-L652
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

No branches or pull requests

2 participants