Class: Admin::PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::PostsController
- Defined in:
- app/controllers/admin/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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' EffectivePosts.(self, :create, @post) if @post.save if params[:commit] == 'Save and Edit Content' && defined?(EffectiveRegions) redirect_to effective_regions.edit_path(effective_posts.post_path(@post), :exit => effective_posts.edit_admin_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 |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/admin/posts_controller.rb', line 68 def destroy @post = Effective::Post.find(params[:id]) EffectivePosts.(self, :destroy, @post) if @post.destroy flash[:success] = 'Successfully deleted post' else flash[:danger] = 'Unable to delete post' end redirect_to effective_posts.admin_posts_path end |
#edit ⇒ Object
42 43 44 45 46 47 |
# File 'app/controllers/admin/posts_controller.rb', line 42 def edit @post = Effective::Post.find(params[:id]) @page_title = 'Edit Post' EffectivePosts.(self, :edit, @post) end |
#index ⇒ Object
7 8 9 10 11 12 |
# File 'app/controllers/admin/posts_controller.rb', line 7 def index @page_title = 'Posts' EffectivePosts.(self, :index, Effective::Post) @datatable = Effective::Datatables::Posts.new() if defined?(EffectiveDatatables) end |
#new ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/admin/posts_controller.rb', line 14 def new @post = Effective::Post.new(:published_at => Time.zone.now) @page_title = 'New Post' EffectivePosts.(self, :new, @post) end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/admin/posts_controller.rb', line 49 def update @post = Effective::Post.find(params[:id]) @page_title = 'Edit Post' EffectivePosts.(self, :update, @post) if @post.update_attributes(post_params) if params[:commit] == 'Save and Edit Content' && defined?(EffectiveRegions) redirect_to effective_regions.edit_path(effective_posts.post_path(@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 |