Skip to content

Commit c319c63

Browse files
authored
Merge pull request #502 from pmackay/pmackay-patch-custom-attributes-doc
Add a note about using custom attributes to README
2 parents 56b549b + a510463 commit c319c63

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,22 @@ Her expects all `User` resources to have an `:organization_id` (or `:_organizati
452452
Her::Errors::PathError: Missing :_organization_id parameter to build the request path. Path is `organizations/:organization_id/users`. Parameters are `{ … }`.
453453
```
454454

455+
#### Associations with custom attributes
456+
457+
Associations can also be made using custom attributes:
458+
459+
```ruby
460+
class User
461+
include Her::Model
462+
belongs_to :owns, class_name: "Organization"
463+
end
464+
465+
class Organization
466+
include Her::Model
467+
has_many :owners, class_name: "User"
468+
end
469+
```
470+
455471
### Validations
456472

457473
Her includes `ActiveModel::Validations` so you can declare validations the same way you do in Rails.

0 commit comments

Comments
 (0)