Class: RuboCop::Cop::Rails::ModelAssociationMissingThrough

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rails/model_association_missing_through.rb

Constant Summary collapse

MSG =
'Association %<association>s references through %<through>s, ' \
'but %<through>s is not defined in this model.'
ASSOCIATION_METHODS =
[
  :belongs_to,
  :has_one,
  :has_many,
  :has_and_belongs_to_many
].freeze

Instance Method Summary collapse

Instance Method Details

#on_class(node) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/rubocop/cop/rails/model_association_missing_through.rb', line 16

def on_class(node)
  return unless model_class?(node)

  associations = find_associations(node)
  return if associations.empty?

  check_missing_through_associations(associations)
end