Post Redirect Get pattern in Rails

前端 未结 6 1301
隐瞒了意图╮
隐瞒了意图╮ 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:47

    I didn't read the question properly.

    The validation failure you have necessitates going to a different page where a different process will occur. You tried to update a domain object, it doesn't exist. The usual response to a validation failure is to re-render the page, but you need to go to the create page.

    The flash hash seems wrong for this. I'd agree with the idea of stuffing your entered data into the session and redirecting.

提交回复
热议问题