post update errors now render the error page with a message
This commit is contained in:
@@ -32,6 +32,15 @@ class PostsController < ApplicationController
|
|||||||
@post = Post.find(params[:id])
|
@post = Post.find(params[:id])
|
||||||
@post.update_attributes(params[:post], :as => CurrentUser.role)
|
@post.update_attributes(params[:post], :as => CurrentUser.role)
|
||||||
respond_with(@post) do |format|
|
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
|
format.json do
|
||||||
render :json => @post.to_json
|
render :json => @post.to_json
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user