我有一个可以分配给电子邮件的 email_templates 表。只能分配一个,因此数据表中有一个单选按钮。当用户选择模板时,它会将 template_id 保存在电子邮件表中。
当我打开电子邮件进行编辑时,我希望模板表已经选择了与该电子邮件关联的电子邮件模板。
这是我的编辑控制器...
def edit
@email_broadcast = EmailBroadcast.active.where("organization_id = ? and id = ?", current_users_user.organization_id, params[:id]).first
respond_to do |format|
format.html
format.json { render json: EmailTemplatesDatatable.new(view_context, false) }
end
end
有什么建议么?谢谢!!
@quincosa
您可以在email_templates.each do |template|
循环中进行检查,例如email.template_if&template.id
. 当您有正匹配时,这意味着您为该电子邮件找到了合适的模板,只需设置单选按钮selected
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句