From 64f6c5661fc8d64390c1f40e35a3ee43c4e43880 Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 21 Feb 2013 11:58:16 -0500 Subject: [PATCH] post update errors now render the error page with a message --- app/controllers/posts_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 0d3112163..c80564cb9 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -32,6 +32,15 @@ class PostsController < ApplicationController @post = Post.find(params[:id]) @post.update_attributes(params[:post], :as => CurrentUser.role) respond_with(@post) do |format| + format.html do + if @post.errors.any? + @error_message = @post.errors.full_messages.join("; ") + render :action => "error" + else + redirect_to post_path(@post) + end + end + format.json do render :json => @post.to_json end