From 504ba12e8cd256b08a43f8ee56c6e2b0272ce6cc Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Sat, 21 Apr 2012 12:01:33 +0200 Subject: Add model validation section to Getting Started guide --- guides/code/getting_started/app/controllers/posts_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'guides/code/getting_started/app/controllers') diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb index e4d83dd279..2ad69a9bcf 100644 --- a/guides/code/getting_started/app/controllers/posts_controller.rb +++ b/guides/code/getting_started/app/controllers/posts_controller.rb @@ -14,7 +14,10 @@ class PostsController < ApplicationController def create @post = Post.new(params[:post]) - @post.save - redirect_to :action => :show, :id => @post.id + if @post.save + redirect_to :action => :show, :id => @post.id + else + render 'new' + end end end -- cgit v1.2.3