从 Rack::Attack 响应设置闪存错误?
我正在尝试设置 flash[:error] 来向用户提供反馈。我一直无法找到有关如何实施的信息。我正在做的一种解决方法是使用查询参数进行重定向并在控制器中获取它,但它很脆弱,而且我遇到了一些错误,turbolinks 有时会使消息渲染两次。
# rack_attack.rb
Rack::Attack.throttled_response = lambda do |env|
headers = {
'Location'=> "/pages/home?error=#{throttle_type}"
}
[301, headers, []]
end
当用户受到限制时设置闪现消息的最佳方法是什么?
I'm trying to set a flash[:error] to give feedback to the user. I haven't been able to find info on how to implement. One workaround I'm doing is to redirect with query params and pick that up in the controller, but it's brittle and I'm getting some errors, turbolinks sometimes makes the message render twice.
# rack_attack.rb
Rack::Attack.throttled_response = lambda do |env|
headers = {
'Location'=> "/pages/home?error=#{throttle_type}"
}
[301, headers, []]
end
What's the best way to set a flash message when a user is throttled?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论