SR061

Severity: error

Summary: has_many or has_one relation is missing required foreign_key field

What this means

A has_many or has_one relation has no foreign_key: attribute. The foreign_key names the column on the related resource’s table that references this resource’s primary key. Without it, Shaperail cannot generate the correct SQL join.

Example that triggers this

relations:
  orders: { resource: orders, type: has_many }

How to fix it

Add foreign_key: <column_on_related_table> to the relation:

orders: { resource: orders, type: has_many, foreign_key: user_id }

Back to top

Shaperail documentation lives in the same repository as the framework so every release has versioned instructions. See the latest release for the most recent version.

This site uses Just the Docs, a documentation theme for Jekyll.