Yes, this is the default behavior. When you post invalid data it renders rather than redirects. One reason is this way you don't need to maintain state across the redirect.
On Feb 5, 2017 3:01 PM, "Hassan Schroeder" <hassan.schroe...@gmail.com> wrote: > On Sat, Feb 4, 2017 at 1:18 PM, Denis K <theef...@gmail.com> wrote: > > > I've stuck in step 5.10: > > def create > > @article = Article.new(article_params) > > if @article.save > > redirect_to @article > > else > > render 'new' > > end > > end > > > > As I understand posting new article with invalid title should invoke else > > statement and render [/new] with error message > > > > It shows error but throws to [http://localhost:3000/articles], instead > of > > [http://localhost:3000/articles/new] > > > > Is it how it supposed to work? > > Yes. > > Note the difference between "redirect_to" which sends a redirect > response header and new URL to the user-agent vs. "render" which > stays at the same URL and provides the content of the "new" view. > > -- > Hassan Schroeder ------------------------ hassan.schroe...@gmail.com > twitter: @hassan > Consulting Availability : Silicon Valley or remote > > -- > 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-talk+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/rubyonrails-talk/CACmC4yAk-XoKLFgzg%2BKqWf% > 3DJXDrhhQ0ud7VJr2m1fxa3zkBt-w%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- 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-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAK5aKaZOSZwtjyev5_4Y%2B2b9o%3Ds1UGTG99Fg%2B4rADMEy-KmYiQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.