Sha256: 9a735f79196b564533ff37fde8cdc8dcee467c3d721981d4c5c3914d9d5a18ae

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module QuicCms
  class Admin::PagesController < ApplicationController
      def index
    @pages = Page.all
  end

  def show
    if params[:permalink]
      @page = Page.find_by_permalink(params[:permalink])
      if @page.nil?
        @page = Page.new(:title => "Page with permalink of #{params[:permalink]} does not exist", :content => "If you are an Admin Please <a href='/users/sign_in'> Log in </a>and create it", :permalink => params[:permalink])
      end
    else
      @page = Page.find(params[:id])
    end
  end

  def new
    @page = Page.new
  end

  def create
    @page = Page.new(params[:page])
    if @page.save
      redirect_to [:admin, @page], :notice => "Successfully created page."
    else
      render :action => '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, @page], :notice  => "Successfully updated page."
    else
      render :action => 'edit'
    end
  end

  def destroy
    @page = Page.find(params[:id])
    @page.destroy
    redirect_to admin_pages_url, :notice => "Successfully destroyed page."
  end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quic_cms-0.0.7 app/controllers/quic_cms/admin/pages_controller.rb
quic_cms-0.0.6 app/controllers/quic_cms/admin/pages_controller.rb