Class: RailsBestPractices::Checks::UseModelAssociationCheck

### Home Classes Methods

### In Files

- lib/rails_best_practices/checks/use_model_association_check.rb

### Parent

RailsBestPractices::Checks::Check

### Methods

- #evaluate_start
- #interesting_nodes

### Files

- LICENSE

### Class/Module Index

Quicksearch

- RailsBestPractices
- RailsBestPractices::Checks
- RailsBestPractices::Checks::AddModelVirtualAttributeCheck
- RailsBestPractices::Checks::AlwaysAddDbIndexCheck
- RailsBestPractices::Checks::Check
- RailsBestPractices::Checks::IsolateSeedDataCheck
- RailsBestPractices::Checks::KeepFindersOnTheirOwnModelCheck
- RailsBestPractices::Checks::LawOfDemeterCheck
- RailsBestPractices::Checks::ManyToManyCollectionCheck
- RailsBestPractices::Checks::MoveCodeIntoControllerCheck
- RailsBestPractices::Checks::MoveCodeIntoHelperCheck
- RailsBestPractices::Checks::MoveCodeIntoModelCheck
- RailsBestPractices::Checks::MoveFinderToNamedScopeCheck
- RailsBestPractices::Checks::MoveModelLogicIntoModelCheck
- RailsBestPractices::Checks::NeedlessDeepNestingCheck
- RailsBestPractices::Checks::NestedModelFormsCheck
- RailsBestPractices::Checks::NotUseDefaultRouteCheck
- RailsBestPractices::Checks::OveruseRouteCustomizationsCheck
- RailsBestPractices::Checks::ReplaceComplexCreationWithFactoryMethodCheck
- RailsBestPractices::Checks::ReplaceInstanceVariableWithLocalVariableCheck
- RailsBestPractices::Checks::UseBeforeFilterCheck
- RailsBestPractices::Checks::UseModelAssociationCheck
- RailsBestPractices::Checks::UseModelCallbackCheck
- RailsBestPractices::Checks::UseObserverCheck
- RailsBestPractices::Checks::UseScopeAccessCheck
- RailsBestPractices::Core
- RailsBestPractices::Core::CheckingVisitor
- RailsBestPractices::Core::Error
- RailsBestPractices::Core::Runner
- Enumerable
- NilClass
- Sexp
- String

No matching classes.

# 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.