为什么从null_session动作重定向不支持rails中的flash
我有一个实际上用作来自我的payment gateway
的return-url
的动作。 因此,为了使它工作,我设置
protect_from_forgery with: :null_session, only: [:verify_payment] def verify_payment data={} params.each do |name, value| data[name]=value end booking=Booking.find(params['booking']) if booking.charge_card(data) redirect_to booking_confirmation_path(booking: data["booking"]), success: "these wont show" else redirect_to booking_summary_path(booking_id: data["booking"]), error: "these wont show" end end
有人可以告诉我闪光灯为什么不能redirect
?
flash.empty?
重定向后会返回true
..为什么?
但如果我渲染它会工作..
您可以指定:notice,:alert或general purpose:flash:
试试这个。
redirect_to booking_confirmation_path(booking: data["booking"]),flash: { success: "Your Success Message" } redirect_to booking_summary_path(booking_id: data["booking"]), flash: { error: "Your Error Message" }
有关更多信息,请参阅此导轨指南 。
- 在Rails的routes.rb中使用尾部斜杠匹配URL
- 调用Rails.application.routes.generate()或Rails.application.routes.recognize_path()时出现’RuntimeError:route set not finalized’