Flash message in redirect not working

前端 未结 4 684
無奈伤痛
無奈伤痛 2020-12-08 14:09

I have the following in my controller:

redirect_to signin_path, :notice => \"The email is already registered\"

In my view I have

4条回答
  •  不知归路
    2020-12-08 14:58

    Do some tail'ing on your logs and see if you're being redirected to multiple actions before you render. If you are, it's likely that flash isn't being kept long enough to make it to the view where it is finally rendered.

    A well-placed flash.keep(:notice) should do the trick.

    Much later edit: Also, in retrospect, if you're redirecting that many times, I highly suggest you do some refactoring and eliminate any unnecessary jumps by consolidating your redirect logic at a higher level, so that your redirects are predetermined and only happen once, twice max.

提交回复
热议问题