54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/admin/posts_controller.rb', line 54
def update
@post = Effective::Post.find(params[:id])
@page_title = 'Edit Post'
authorize_effective_posts!
if @post.update_attributes(post_params)
if params[:commit] == 'Save and Edit Content'
redirect_to effective_regions.edit_path(effective_posts.post_path(@post), :exit => effective_posts.edit_admin_post_path(@post))
elsif params[:commit] == 'Save and Add New'
flash[:success] = 'Successfully updated post'
redirect_to effective_posts.new_admin_post_path
elsif params[:commit] == 'Save and View'
redirect_to effective_posts.post_path(@post)
elsif params[:commit] == 'Duplicate'
begin
post = @post.duplicate!
flash[:success] = 'Successfully saved and duplicated post.'
flash[:info] = "You are now editing the duplicated post. This new post has been created as a Draft."
rescue => e
flash.delete(:success)
flash[:danger] = "Unable to duplicate post: #{e.message}"
end
redirect_to effective_posts.edit_admin_post_path(post || @post)
else
flash[:success] = 'Successfully updated post'
redirect_to effective_posts.edit_admin_post_path(@post)
end
else
flash.now[:danger] = 'Unable to update post'
render :action => :edit
end
end
|