Skip to content

has_one foreign_key_on: :related fails on save #670

Open
@blmundie

Description

@blmundie

When saving a resource with a has_one relationship with foreign_key_on: :related I get an error of undefined method 'foreign_key=' for the model. I'm not sure if the intent is to change the relationship on the related items when save or not. For now I did the following patch to not update any relationships that have foreign_key_on: :related

def replace_to_one_link(relationship_type, relationship_key_value)
  if(self.class._relationships[relationship_type.to_sym]).belongs_to?
    super
  end
end

def replace_polymorphic_to_one_link(relationship_type, relationship_key_value, relationship_key_type)
  if(self.class._relationships[relationship_type.to_sym]).belongs_to?
    super
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions