Skip to content

Commit

Permalink
UDF #6 - Adding model documentation to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Sep 21, 2022
1 parent 1e84fd2 commit 3711aaf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class AddUserDefinedFieldsToMyModel < ActiveRecord::Migration[7.0]
end
```

### Models
Models that include the `UserDefinedFields::Fieldable` concern will be treated as the models that store the user defined data. The will be available in the dropdown list when configuring user defined fields.

Applications that define user defined fields at the model level should call `resolve_defineable` class method with a lambda function that returns the `defineable` model.
```ruby
class MyModel < ApplicationRecord
include UserDefinedFields::Fieldable

resolve_defineable -> (my_model) { my_model.parent }
end
```

### Components

User defined fields can be configured one of two ways: At the application level, or at the model level.
Expand Down

0 comments on commit 3711aaf

Please sign in to comment.