Module: Graphiti::Adapters::ActiveRecord::Inference

Included in:
BelongsToSideload, HasManySideload, HasOneSideload
Defined in:
lib/graphiti/adapters/active_record/inference.rb

Instance Method Summary collapse

Instance Method Details

#infer_foreign_keyObject

If going AR to AR, use AR introspection If going AR to PORO, fall back to normal inference



4
5
6
7
8
9
10
11
12
13
# File 'lib/graphiti/adapters/active_record/inference.rb', line 4

def infer_foreign_key
  parent_model = parent_resource_class.model
  reflection = parent_model.reflections[association_name.to_s]
  if reflection
    reflection = proper_reflection(reflection)
    reflection.foreign_key.to_sym
  else
    super
  end
end