Was ist dieser add_to_serializer Code in all diesen Plugins

I’m working on a plugin to automate discourse group syncing with ldap. I added a custom field to Group (ldap_dn) to save the ldap group name in. I’m trying to retrieve the custom_field value from an input field that i added in the membership plugin-outlet and save that to the db to later use it.

To do so i added this to my plugin.rb file

Group.register_custom_field_type(‘ldap_dn’, :text)
Group.preload_custom_fields<< “ldap_dn” if
Group.respond_to? :preloaded_custom_fields

if SiteSetting.groups_sync_enabled then
add_to_serializer(:group_show, :custom_fields, false) {
object.custom_fields
}
end

I’m new to rails and ember so I’m not sure if there is another step I should be doing in order to get the custom_fields saved to the db, or where the problem lies.

1 „Gefällt mir“