How to display a flash message after multiple redirects?

时间:2015-09-01 23:01:16

标签: ruby-on-rails redirect flash-message

So I'm trying to display a flash after multiple redirects, but I can't get it to "keep"! I tested out the code in my view file, and that's solid. What am I missing?

if response["status"] == "NotProcessed"
  redirect_to root_path, alert: "Does this work?"

That takes me back tot he root path, but no flash is displayed, so I added flash.keep, and still nothing. I even added:

      def redirect_to(*args)
        flash.keep
        super
      end

to my application controller... but nothing!

Thanks!

1 个答案:

答案 0 :(得分:0)

固定!

我在ApplicationController中设置了protect_from_forgery with: :null_session,因此每次会话都删除了flash。我删除了它,它工作正常。

在处理天气API时,我必须在应用程序的早期插入。