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/HasManyOrHasOneDependent is't applicable if target table is readonly #393

Closed
francesco-loreti opened this issue Nov 26, 2020 · 1 comment

Comments

@francesco-loreti
Copy link

francesco-loreti commented Nov 26, 2020

Hi,
I have an alert about

 convention: Rails/HasManyOrHasOneDependent: Specify a :dependent option.

But this warning is not applicable if the target table is readonly(for example view or materialized view).

has_many :books, source: :store, dependent: ????

There's a solution?


RuboCop version

rubocop -V
1.4.2 (using Parser 2.7.2.0, rubocop-ast 1.2.0, running on ruby 2.7.2 x64-mingw32)
  - rubocop-rails 2.8.1
@koic
Copy link
Member

koic commented May 8, 2021

You can specify dependent: nil is specified if do nothing and RuboCop Rails 2.10 will ignore it.
https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_one

Related issue: #147

@koic koic closed this as completed May 8, 2021
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