提交不允许的参数时如何引发异常? [英] How to raise an exception when unpermitted parameters are submitted?
本文介绍了提交不允许的参数时如何引发异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里找到了这段代码:
ActionController::Parameters.action_on_unpermitted_parameters = :raise
我尝试将它放在 config/environments/development.rb
中,但它似乎不起作用.我应该把它放在哪里?(我只想要这个用于开发环境.)
I tried putting this in config/environments/development.rb
, but it didn't seem to work. Where should I put it? (I only want this for development env.)
推荐答案
放入config/environments/development.rb
config.action_controller.action_on_unpermitted_parameters = :raise
这将引发 ActionController::UnpermittedParameters
这篇关于提交不允许的参数时如何引发异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文