ruby on rails - How to make a render :edit call show the /edit in the address bar -


In the update action of my preferences controller in my Rail app, if there are any errors / save in the verification call:

format.html {render: edit}

There is not any uncommon - however, when this code gets hit, the address in the browser For example:

For example:

To start with this, my browser shows that I On the page at the following address:

However, once the errors are detected and render, it is converted into an address

I can not say that I have never Have seen behavior - but is there a way to compel the edit / stay at the end of the URL?

Instead of calling "post-text" itemprop = "text">

render , you can edit redirect_to on the edit page, and flash To keep track of the model:

  def update # ... if !@model.save # was an error! Flash [: model] = @ModelRedirect_to: Action = & gt; In the action you can reload the meaning from  flash [: model] :   

and then edit Meaning:

  def edit flash [: model] @model = flash [: model] and @model = ... # load model normally end expiration  

Update:

As noted below, I feel that when I wrote this reply, I was trying to provide both a method to update the URL (Which requires a redirection) and replaces the model's changed features, which is why the model was stored in Flash. However, it is a very bad idea to paste a model into Flash (and it will be deserialized anyway in later versions of the railroad), and the lush routes actually need to be edit in the URL is not.

Normal pattern must already be present in the memory with the model editing operation, and should leave the "ideal" url:

  def update # properties Models to assign if the @model.php in the form params: save redirect_toAct :: Index array render: end and editing and end  

Alternatively, if the "ideal" URL is better for And you do not care to keep up the failures of verification In Ray, see @JamesMarkKook's answer.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -