post update errors now render the error page with a message

This commit is contained in:
albert
2013-02-21 11:58:16 -05:00
parent 74d66ccb58
commit 64f6c5661f

View File

@@ -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