Sha256: c4d73fc868b8f7137b9d5ec5c28d7b33820f081e96261140e3bd47dd97b2afe2
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
class Admin::Carousel::SlidesController < Admin::Carousel::BaseController before_filter :load_carousel before_filter :build_slide, :only => [:new, :create] before_filter :load_slide, :only => [:edit, :update, :destroy] def index @slides = @carousel.slides 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 def reorder (params[:carousel_slide] || []).each_with_index do |id, index| Carousel::Slide.where(:id => id).update_all(:position => index) end render :nothing => true end protected def build_slide # Yes, this is terrible. Thank paperclip for that. @slide = Carousel::Slide.new({:carousel => @carousel}.merge(params[:slide] || {})) end def load_slide @slide = @carousel.slides.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = 'Slide not found' redirect_to :action => :index end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comfy_carousel-0.0.3 | app/controllers/admin/carousel/slides_controller.rb |
comfy_carousel-0.0.2 | app/controllers/admin/carousel/slides_controller.rb |