如何使ActiveAdmin使用强参数? [英] How to get ActiveAdmin to work with Strong Parameters?

查看:77
本文介绍了如何使ActiveAdmin使用强参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:在ActiveAdmin中已经存在针对此问题的解决方案之前,曾提出此问题。如约瑟夫所说,ActiveAdmin文档现在包含此信息,但是此处提供的答案适用于使用较旧版本的ActiveAdmin的人。

strong_parameters 0.1时.4与Rails 3.2.8中的ActiveAdmin 0.5.0一起使用,如果您使用的模型通过以下方式使用StrongParameters:

When the strong_parameters 0.1.4 is used with ActiveAdmin 0.5.0 in Rails 3.2.8, if the model you are using is using StrongParameters by including:

include ::ActiveModel::ForbiddenAttributesProtection

然后,如果您尝试在日志中得到以下错误创建/编辑记录:

then you get the following error in the log if you try to create/edit a record:

ActiveModel::ForbiddenAttributes (ActiveModel::ForbiddenAttributes)


推荐答案

文档现在清楚地说明了如何在Rails 4中设置强参数。请参见:

The documentation now clearly states how to go about Setting up Strong Parameters in Rails 4. See:

https://github.com/gregbell/active_admin/blob/master/docs/2-resource-cus tomization.md#setting-up-strong-parameters

这篇关于如何使ActiveAdmin使用强参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆