Class: Hitchens::Admin::PostsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- Hitchens::ApplicationController
- BaseController
- Hitchens::Admin::PostsController
- Defined in:
- app/controllers/hitchens/admin/posts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from Hitchens::ApplicationController
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 15 def create if @post.save flash[:notice] = t 'hitchens.notices.post_created' redirect_to admin_posts_path else render 'new' end end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 37 def destroy @post.destroy flash[:notice] = t('hitchens.notices.post_deleted') redirect_to admin_posts_path end |
#edit ⇒ Object
35 36 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 35 def edit end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 6 def index @posts = @posts.page(params[:page]).per_page(Hitchens.posts_per_page) @posts = PostDecorator.decorate @posts end |
#new ⇒ Object
33 34 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 33 def new end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 11 def show @post = PostDecorator.decorate @post end |
#update ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 23 def update if @post.update_attributes params[:post] flash[:notice] = t 'hitchens.notices.post_updated' redirect_to admin_posts_path else flash[:error] = t 'hitchens.errors.post_not_updated' render 'edit' end end |