Sha256: a0cf3e18328419959e2ddfd48f989bdd0c38e62674e6b06eb6f1a9258c51c0b4

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

class Admin::Carousel::SlidesController < CmsAdmin::BaseController
  
  before_filter :build_slide, :only => [:new, :create]
  before_filter :load_slide,  :only => [:edit, :update, :destroy]
  
  def index
    @slides = Slide.order('id DESC').page(params[:page])
  end

  def new
    render
  end

  def edit
    render
  end

  def create
    @slide.save!
    flash[:notice] = 'Slide created'
    redirect_to :action => :index
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to create Slide'
    render :action => :new
  end

  def update
   @slide.update_attributes!(params[:slide])
    flash[:notice] = 'Slide updated'
    redirect_to :action => :edit
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to update Slide'
    render :action => :edit
  end

  def destroy
    @slide.destroy
    flash[:notice] = 'Slide deleted'
    redirect_to :action => :index
  end

protected

  def build_slide
    @slide = Slide.new(params[:slide])
  end

  def load_slide
    @slide = Slide.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    flash[:error] = 'Slide not found'
    redirect_to :action => :index
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfy_carousel-0.0.0 app/controllers/admin/carousel/slides_controller.rb