21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/admin/posts_controller.rb', line 21
def create
@post = Effective::Post.new(post_params)
@post.user = current_user if defined?(current_user)
@page_title = 'New Post'
authorize_effective_posts!
if @post.save
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 created post'
redirect_to effective_posts.new_admin_post_path
elsif params[:commit] == 'Save and View'
redirect_to effective_posts.post_path(@post)
else
flash[:success] = 'Successfully created post'
redirect_to effective_posts.edit_admin_post_path(@post)
end
else
flash.now[:danger] = 'Unable to create post'
render :action => :new
end
end
|