From 3711aaf1b5fb8d7ac2a85fff70bcba4fada51cb6 Mon Sep 17 00:00:00 2001 From: Derek Leadbetter Date: Wed, 21 Sep 2022 15:58:16 -0400 Subject: [PATCH] UDF #6 - Adding model documentation to README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 563829a..bd833f4 100644 --- a/README.md +++ b/README.md @@ -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.