Class: SofaBlog::Admin::PostsController
- Inherits:
-
BaseController
- Object
- BaseController
- SofaBlog::Admin::PostsController
- Defined in:
- app/controllers/sofa_blog/admin/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 14 def create @post.save! flash[:notice] = 'Blog post created' redirect_to :action => :index rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to create BlogPost' render :action => :new end |
#destroy ⇒ Object
36 37 38 39 40 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 36 def destroy @post.destroy flash[:notice] = 'Blog post removed' redirect_to :action => :index end |
#edit ⇒ Object
23 24 25 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 23 def edit render end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 6 def index @posts = SofaBlog::Post.order('created_at DESC') end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 10 def new @post.is_published ||= true end |
#update ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/sofa_blog/admin/posts_controller.rb', line 27 def update @post.update_attributes!(params[:post]) flash[:notice] = 'Blog post updated' redirect_to :action => :index rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to update BlogPost' render :action => :edit end |