简体   繁体   English

第一次表单/模型验证失败后,URL参数丢失

[英]URL parameter lost after first form/model validation failure

I am using a guid to be used as a parameter during the creation of a new user. 我在创建新用户的过程中使用了GUID作为参数。 The route for this is defined as following: 为此的路由定义如下:

  match 'add_user/:guid', :to => 'users#new', :as => :add_user, :via => :get 

The problem is that when validation fails (ie. empty first name, etc.), the 'new' method reloads without the appended guid as was the case on the first load. 问题是,当验证失败时(例如,空名,等等),“新”方法将重新加载,而没有附加的guid,这与第一次加载时的情况相同。

The form reloads with the validation error and 表单将重新加载并显示验证错误,然后

/users

as the URL. 作为网址。 The guid is lost. 向导丢失了。

Is there a way to preserve the guid between the various requests that occurs as the user input is being validated? 有没有一种方法可以在验证用户输入时保留各种请求之间的guid?

How about making a hidden input with the guid? 如何使用guid进行隐藏输入? Or changing action POST path to be the same as GET and passing the guid in the URL again? 还是将action POST路径更改为与GET相同,然后再次在URL中传递GUID?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM