Files

RailsBestPractices::Checks::UseModelAssociationCheck

Check a model creation to make sure using model association.

Implementation:

  1. check :attrasgn, if xxx_id is assigned to a variable, set the value of the assigned variable to true.

  2. check :call, if call message :save and caller is included in variables, add error.

Public Instance Methods

evaluate_start(node) click to toggle source
# File lib/rails_best_practices/checks/use_model_association_check.rb, line 16
def evaluate_start(node)
  @variables = {}
  node.recursive_children do |child|
    case child.node_type
    when :attrasgn
      attribute_assignment(child)
    when :call
      call_assignment(child)
    else
    end
  end
  @variables = nil
end
interesting_nodes() click to toggle source
# File lib/rails_best_practices/checks/use_model_association_check.rb, line 12
def interesting_nodes
  [:defn]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.