Rails 5.0.0.beta4 在包含动态 :action 和 :controller 段的路由上引入了弃用警告:
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 5.1.
此 PR 的提交消息 https://github.com/rails/rails/pull/23980状态:
允许通过路径指定 :controller 和 :action 值
config/routes.rb 中的问题是导致许多问题的根本原因
Rails 中已导致安全发布。有鉴于此
最好将控制器和操作明确列入白名单
而不是试图将“坏”值列入黑名单或清理掉。
您将如何将一组操作参数“列入白名单”?我的路由文件中有以下内容,它们引发了弃用警告:
namespace :integrations do
get 'stripe(/:action)', controller: 'stripe', as: "stripe"
post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
end
虽然有点麻烦,但最好的方法似乎是明确定义路线:
namespace :integrations do
namespace 'stripe' do
%w(auth webhook activate).each do |action|
get action, action: action
end
end
post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)