Sha256: b505c2c3b4e751bea02cb325aab5ba8a02d60f4301186dbe0a35675b55e809e9

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module Admin
  class PagesController < BaseController
  
    layout "admin"
  
    before_filter :authenticate_user!
    access_control do
      allow :admin
    end
  
    def index
      @search = Page.includes(:category).search(params[:search])
      @pages = @search.order("created_at desc").page(params[:page])
    end
  
    def new
      @page = Page.new
    end
  
    def create
      @page = Page.new(params[:page])
      if @page.save
        redirect_to admin_pages_path
      else
        render :new
      end
    end
  
    def edit
      @page = Page.find(params[:id])
    end
  
    def update
      @page = Page.find(params[:id])
      if @page.update_attributes(params[:page])
        redirect_to admin_pages_path
      else
        render :edit
      end
    end
  
    def destroy
      page = Page.find(params[:id])
      page.destroy
      redirect_to admin_pages_path
    end
  
    def publish
      page = Page.find(params[:id])
      page.publish!
      redirect_to admin_pages_path
    end
  
    def unpublish
      page = Page.find(params[:id])
      page.unpublish!
      redirect_to admin_pages_path
    end
  
    def archive
      page = Page.find(params[:id])
      page.archive!
      redirect_to admin_pages_path
    end
  
    def unarchive
      page = Page.find(params[:id])
      page.unarchive!
      redirect_to admin_pages_path
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
merrycms-0.1.7 app/controllers/admin/pages_controller.rb
merrycms-0.1.4 app/controllers/admin/pages_controller.rb