Exception: Graphiti::Errors::PolymorphicSideloadChildNotFound

Inherits:
Base
  • Object
show all
Defined in:
lib/graphiti/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(sideload, name) ⇒ PolymorphicSideloadChildNotFound

Returns a new instance of PolymorphicSideloadChildNotFound.



674
675
676
677
# File 'lib/graphiti/errors.rb', line 674

def initialize(sideload, name)
  @sideload = sideload
  @name = name
end

Instance Method Details

#messageObject



679
680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'lib/graphiti/errors.rb', line 679

def message
  <<~MSG
    #{@sideload.parent_resource}: Found record with #{@sideload.grouper.field_name.inspect} == #{@name.inspect}, which is not registered!

    Register the behavior of different types like so:

    polymorphic_belongs_to #{@sideload.name.inspect} do
      group_by(#{@sideload.grouper.field_name.inspect}) do
        on(#{@name.to_sym.inspect}) <---- this is what's missing
        on(:foo).belongs_to :foo, resource: FooResource (long-hand example)
      end
    end
  MSG
end