我正在开发一个插件,用于自动化 Discourse 群组与 LDAP 的同步。我为 Group 添加了一个自定义字段(ldap_dn),用于保存 LDAP 群组名称。我试图从我在 membership plugin-outlet 中添加的输入字段中获取 custom_field 的值,并将其保存到数据库中,以便后续使用。
为此,我在 plugin.rb 文件中添加了以下内容:
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
作为 Rails 和 Ember 的新手,我不确定是否还有其他步骤需要执行,以便将 custom_fields 保存到数据库中,或者问题出在哪里。