Sha256: d29a9fcc57291caf0dd6fd98060606922233d8357bad6162bf4680caf025ad26

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

class IllustrationsController < ApplicationController

  before_filter :authenticate
  before_filter :authenticate_with_admin

  def index
    @illustrations = Illustration.by_recent.paginate(:page => params[:page], :per_page => 25)
    switch_to_admin_layout
  end

  def show
    @illustration = Illustration.find(params[:id])
    switch_to_admin_layout
  end

  def new
    @illustration = Illustration.new
    switch_to_admin_layout
  end

  def edit
    @illustration = Illustration.find(params[:id])
    switch_to_admin_layout
  end

  def create
    @illustration = Illustration.new(illustration_params)
    if @illustration.save
      redirect_to @illustration, notice: t('illustrations.create.notice')
    else
      render action: "new", layout: 'admin'
    end
  end

  def update
    @illustration = Illustration.find(params[:id])
    if @illustration.update_attributes(illustration_params)
      redirect_to @illustration, notice: t('illustrations.update.notice')
    else
      render action: "edit", layout: 'admin'
    end
  end

  def destroy
    @illustration = Illustration.find(params[:id])
    @illustration.destroy
    redirect_to illustrations_url
  end

  private

  # Never trust parameters from the scary internet, only allow the white list through.
  def illustration_params
    params.require(:illustration).permit(:name, :image)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tkh_illustrations-0.9.1 app/controllers/illustrations_controller.rb