Sha256: 219f6f5621ed0560bdfdf8f514642f7172e9b924cd30daa8f2e18ed8e3bb8485

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Hitchens
  module Admin
    class PostsController < BaseController
      load_and_authorize_resource :class => 'Hitchens::Post'

      def index
        @posts = @posts.page(params[:page]).per_page(Hitchens.posts_per_page)
        @posts = PostDecorator.decorate @posts
      end

      def show
        @post = PostDecorator.decorate @post
      end

      def create
        if @post.save
          flash[:notice] = t 'hitchens.notices.post_created'
          redirect_to admin_posts_path
        else
          render 'new'
        end
      end
      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

      def new
      end
      def edit
      end
      def destroy
        @post.destroy
        flash[:notice] = t('hitchens.notices.post_deleted')
        redirect_to admin_posts_path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hitchens-0.0.3 app/controllers/hitchens/admin/posts_controller.rb
hitchens-0.0.2 app/controllers/hitchens/admin/posts_controller.rb