-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This gem looks helpful to solve the issue described in codica2/administrate-field-jsonb#1, thanks!
However it does not seem to support nested fields. I have a Post dashboard configured as follows (schema was configured by globalize):
# app/dashboards/post_dashboard.rb
class PostDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
translations: NestedHasMany.with_options(class_name: "Post::Translation"),
...
}.freeze
...
end
# app/dashboards/post/translation_dashboard.rb
class Post::TranslationDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
tags: Field::JSONB,
...
}.freeze
...
endThe aim is to apply deserialize_json_fields to the tags field of the post translation.
NB: NestedHasMany is a modification of Field::NestedHasMany to support namespaced models, as shown here.
There are two problems:
- the README instructs to define
deserialize_json_fieldson the controller, but bothAdmin::Post::TranslationsControllerandAdmin::PostsControllerwill potentially need to handle the submission oftags(respectively either being a direct property of the resource associated to the controller, or as a property of the nested sub-resource through the has-many relation) - there is no way with the current syntax to instruct to deserialize the field in the nested resource (which is the scenario I need the most). The transformation should actually be applied not on
tags, but on the form'stranslations_attributesvalue which looks like this:
{
"0"=>{"id"=>"19", "_destroy"=>"false", "locale"=>"en", "tags"=>"[\"in english\"]", ...},
"1"=>{"id"=>"20", "_destroy"=>"false", "locale"=>"fr", "tags"=>"[\"en français\"]", ...}
}Metadata
Metadata
Assignees
Labels
No labels