Rails validation over redirect

后端 未结 3 984
猫巷女王i
猫巷女王i 2020-11-30 02:39

I\'m trying out the beast forum written in rails and will use this as an example of a problem I keep facing.

The forum has a topics/show action and view with a form

3条回答
  •  甜味超标
    2020-11-30 03:28

    I'm afraid I don't know anything about Beast, but speaking generically, everything is lost when you redirect. It's a new page request, and everything is reset unless it's been stored somewhere (the database or the session, normally.)

    The normal flow you tend to see with forms is to redirect if the object is saved, but to render if the save fails. The view file can then pick up whatever variables have been set in the controller - which would normally include the object that didn't save and its validation messages.

    Sorry that doesn't solve your problem, but hopefully it may give you some clues.

提交回复
热议问题