You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The contents model is quite flexible right now, but it's still a bit restrictive for things that extrapolate the title+description+images combination.
By adding a custom_attributes field in the cas_contents field, we can add any new input to the forms without having to change database schema. By configuring cas.yml, this format can be checked out on Git so developers can review changes.
Acceptance criteria
create cas.yml spec for defining custom attributes, which will make new input fields be shown in the forms, as well as data be automatically saved in the respective column.
add custom_attributes JSONB column (array) to cas_contents table.
create inputs in the ContentsController forms for creating and updating data, showing the fields that were defined in the cas.yml file.
create methods in the Cas::Content model for saving and retrieving custom attributes
Technical details
I imagine the model to have something similar to the following pseudocode:
classCas::Content < ActiveRecord::BaseCUSTOM_ATTRIBUTES_KEYS=["key","value"].freeze# ...# `custom_attributes` has the following format:## [{# "key": "name",# "value": "John Doe"# }]## The type of the field (string|integer|boolean) are stored in the yml filedefcustom_attributes=(value)self[:custom_attributes]=value.mapdo |hash|
hash.keep_if{ |key,_| CUSTOM_ATTRIBUTES_KEYS.include?(key.to_s)}endenddefcustom_attribute(key)Array.wrap(custom_attributes).find{ |attr| attr["key"] == key.to_s} || {}end# ...end
The text was updated successfully, but these errors were encountered:
The
contents
model is quite flexible right now, but it's still a bit restrictive for things that extrapolate the title+description+images combination.By adding a
custom_attributes
field in thecas_contents
field, we can add any new input to the forms without having to change database schema. By configuring cas.yml, this format can be checked out on Git so developers can review changes.Acceptance criteria
custom_attributes
JSONB column (array) tocas_contents
table.Cas::Content
model for saving and retrieving custom attributesTechnical details
I imagine the model to have something similar to the following pseudocode:
The text was updated successfully, but these errors were encountered: