Sha256: 84600522e673796d6247caa1abf8827e2c0192a6e399c7250a3738b24e39c71c

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

class Admin::BannerSetsController < Admin::ApplicationController

  before_filter :get_record, :only => [:show, :edit, :update, :destroy]
  respond_to :html
  belongs_to_spud_app :banner_sets
  add_breadcrumb 'Banner Sets', :admin_banner_sets_path
  layout false

  def index
    @banner_sets = SpudBannerSet.all
    respond_with @banner_sets, :layout => 'admin/detail'
  end

  def show
    respond_with @banner_set, :layout => 'admin/detail'
  end

  def new
    @banner_set = SpudBannerSet.new
    respond_with @banner_set
  end

  def create
    @banner_set = SpudBannerSet.new(banner_set_params)
    if @banner_set.save
      flash.now[:notice] = 'BannerSet created successfully' 
      render 'create'
    else
      render 'new', :status => 422
    end
  end

  def edit
    respond_with @banner_set
  end

  def update
    if @banner_set.update_attributes(banner_set_params)
      flash.now[:notice] = 'BannerSet updated successfully'
      render 'create'
    else
      render 'edit', :status => 422
    end
  end

  def destroy
    if @banner_set.destroy
      flash.now[:notice] = 'BannerSet deleted successfully' 
    end
    render :nothing => true
  end

private

  def get_record
    begin
      @banner_set = SpudBannerSet.find(params[:id])
    rescue ActiveRecord::RecordNotFound => e
      flash.now[:error] = "Could not find the requested BannerSet"
      redirect_to admin_banner_sets_path
      return false
    end
  end

  def banner_set_params
    params.require(:spud_banner_set).permit(:cropped, :height, :name, :short_name, :width, :has_rich_text)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tb_banners-1.2.0 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.6 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.2.0.beta1 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.5 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.4 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.3 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.2 app/controllers/admin/banner_sets_controller.rb
tb_banners-1.1.1 app/controllers/admin/banner_sets_controller.rb