I have an action which is actually used as a return-url
from my payment gateway
. So for making it work I set
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
could some one tell me why the flash wont work on redirect
?
flash.empty?
will return true
after redirect..why is that?
But if I render it will work..
could some one tell me why the flash wont work on redirect?
Because you are setting protect_from_forgery with: :null_session
for the controller's verify_payment
action.
Rails' flash messages are stored in the user's session, which you are expressly setting to be empty. No session, no flash messages.
FWIW, if you can find some other means of determining the response form the payment gateway (a querystring maybe?) you can use flash.now('whatever')
in the controller you are redirecting to.