Post Redirect Get pattern in Rails

前端 未结 6 1330
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 15:19

How can I implement PRG in Rails?

I used PRG in Rails, but I am not totally convinced it\'s right. I was wondering is there any better way to handle it in Rails?

6条回答
  •  难免孤独
    2021-01-05 15:42

    I'm no expert in these matters, but this looks good. From what I understand flash is a part of the session. So the answers telling you to switch to session seem a bit misguided. In this case you want the data to be cleared after the redirect. Other than shoving it in the session, I'm not sure where you would put it.

    As far as your cookie size increasing, well, the default session provider for Rails is a cookie in Rails 3. You could swap the session provider out if you wanted to keep the data server side. It is encrypted though, so you are probably okay with the data in the cookie, unless size is an issue.

提交回复
热议问题