Exception: NestedAttributeReassignable::RelationExists

Inherits:
StandardError
  • Object
show all
Defined in:
lib/nested_attribute_reassignable.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, relation) ⇒ RelationExists

Returns a new instance of RelationExists.



6
7
8
9
# File 'lib/nested_attribute_reassignable.rb', line 6

def initialize(model, relation)
  @model = model.class.name.pluralize.underscore
  @relation = relation
end

Instance Method Details

#messageObject



11
12
13
14
15
16
17
# File 'lib/nested_attribute_reassignable.rb', line 11

def message
  "Relation '\#{@relation}' already exists on '\#{@model}' object but attributes were passed with no id.\n\nIt is invalid to create a new '\#{@relation}' relation when one already exists, as it would leave orphaned records. Update the existing record instead.\n  STR\nend\n"