Sha256: 7c606986ce295774c7436fe4533ae115af015e8008725987029adbe365260d6d

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

class Admin::Carousel::CarouselsController < Admin::Carousel::BaseController
  
  before_filter :build_carousel,  :only => [:new, :create]
  before_filter :load_carousel,   :only => [:edit, :update, :destroy]
  
  def index
    @carousels = Carousel::Carousel.all
  end
  
  def new
    render
  end
  
  def edit
    render
  end
  
  def create
    @carousel.save!
    flash[:notice] = 'Carousel created'
    redirect_to new_admin_carousel_carousel_slide_path(@carousel)
  
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to create Carousel'
    render :action => :new
  end
  
  def update
    @carousel.update_attributes!(params[:carousel])
    flash[:notice] = 'Carousel updated'
    redirect_to :action => :edit, :id => @carousel
    
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to update Carousel'
    render :action => :edit
  end
  
  def destroy
    @carousel.destroy
    flash[:notice] = 'Carousel removed'
    redirect_to :action => :index
  end
  
protected
  
  def build_carousel
    @carousel = Carousel::Carousel.new(params[:carousel])
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfy_carousel-0.0.3 app/controllers/admin/carousel/carousels_controller.rb
comfy_carousel-0.0.2 app/controllers/admin/carousel/carousels_controller.rb
comfy_carousel-0.0.1 app/controllers/admin/carousel/carousels_controller.rb