Nemate dopuštenje za brisanje poruka u ovoj grupi.
Kopiraj vezu
Prijavi poruku
Prijavite se da biste prijavili poruku
Prikaži izvornu poruku
E-adrese za tu grupu su anonimne ili trebate dopuštenje za prikaz e-adresa članova da biste vidjeli izvornu poruku
u Ruby on Rails: Talk
my controller is user_posts_controller.rb it's views are in /app/views/user/posts
when a form submission fails to save the object i wanna redirect back to the custom pathed form i came from but the controller code has render :new
how do i redirect to the calling path of new and pass parameters
Walter Lee Davis
nepročitano,
25. velj 2017. 10:40:0325. 02. 2017.
Odgovori autoru
Prijavite se da biste odgovorili autoru
Proslijedi
Prijavite se da biste proslijedili
Izbriši
Nemate dopuštenje za brisanje poruka u ovoj grupi.
Kopiraj vezu
Prijavi poruku
Prijavite se da biste prijavili poruku
Prikaži izvornu poruku
E-adrese za tu grupu su anonimne ili trebate dopuštenje za prikaz e-adresa članova da biste vidjeli izvornu poruku
u rubyonra...@googlegroups.com
After an error, you really don't want to redirect, just re-render. That's how you keep all the request variables alive. If you need to render a different form from a different path, just pass in that path to your controller. Remember, in the error side of the if/else, there is an implicit render template: [:new or :edit]. So you can also write render template: 'path/to/custom/view' there. The rest of the variables will already be there.
Nemate dopuštenje za brisanje poruka u ovoj grupi.
Kopiraj vezu
Prijavi poruku
Prijavite se da biste prijavili poruku
Prikaži izvornu poruku
E-adrese za tu grupu su anonimne ili trebate dopuštenje za prikaz e-adresa članova da biste vidjeli izvornu poruku
u Ruby on Rails: Talk
I think you can use :back.
redirect_to :back
Walter Lee Davis
nepročitano,
28. velj 2017. 17:21:0028. 02. 2017.
Odgovori autoru
Prijavite se da biste odgovorili autoru
Proslijedi
Prijavite se da biste proslijedili
Izbriši
Nemate dopuštenje za brisanje poruka u ovoj grupi.
Kopiraj vezu
Prijavi poruku
Prijavite se da biste prijavili poruku
Prikaži izvornu poruku
E-adrese za tu grupu su anonimne ili trebate dopuštenje za prikaz e-adresa članova da biste vidjeli izvornu poruku
u rubyonra...@googlegroups.com
When you redirect, you lose all of the current environment (including the error, why it happened, etc.). This is almost never what you want to do. You want to fall through to re-render the form, and it will properly display the error messages and allow the user to recover without re-entering all of the data again. Use the rails scaffold command to make a new model/controller/view. Look at what it does. This is the expected behavior that you differ from at your peril!
Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.