You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and you define an has_many relation such as: has_many :foos, foreign_key: :bar_id, then it does not make sense to enforce a dependent option.
Maybe this cop should be ignored when the class is readonly?, or at least be configurable to ignore those.
Do you think this is worthwhile?
I can try to implement this, but I actually don't really now if there are good determinist ways to detect if the class is readonly?, maybe just checking that the method is defined and that it evals to true? Sounds complicated, and dangerous...
The text was updated successfully, but these errors were encountered:
…donly?` is `true`
Fixesrubocop#137.
This PR makes `Rails/HasManyOrHasOneDependent` aware of `readonly?` is `true`.
There may be false positives or false negatives with just `def readonly? = true`,
but it makes it possible to detect perhaps general definition of `readonly?` method.
…donly?` is `true`
Fixesrubocop#137.
This PR makes `Rails/HasManyOrHasOneDependent` aware of `readonly?` is `true`.
There may be false positives or false negatives with just `def readonly? = true`,
but it makes it possible to detect perhaps general definition of `readonly?` method.
When you a have a readonly model (for example a model backed by a database view):
and you define an
has_many
relation such as:has_many :foos, foreign_key: :bar_id
, then it does not make sense to enforce adependent
option.Maybe this cop should be ignored when the class is
readonly?
, or at least be configurable to ignore those.Do you think this is worthwhile?
I can try to implement this, but I actually don't really now if there are good determinist ways to detect if the class is
readonly?
, maybe just checking that the method is defined and that it evals to true? Sounds complicated, and dangerous...The text was updated successfully, but these errors were encountered: