Sha256: 1b3210c750d217d0dc0e9d4f5e402c30d823c57fac1fdc6018a17ddd99be9ab6

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

class Spree::Admin::BulletsController < Spree::Admin::BaseController
  respond_to :html

  before_filter :load_parent
  
  def index
    @bullets = Spree::Bullet.sorted_by_image_code.where(:taxon_id => @taxon.id)
    respond_with(:admin, @taxonomy, @taxon) 
  end
  
  def new
    @bullet = Spree::Bullet.new(:taxon_id => @taxon.id, :is_active => true)
  end
  
  def create
    @bullet = Spree::Bullet.new(params[:bullet].merge(:taxon_id => @taxon.id))
    
    if @bullet.save
      flash[:notice] = t(:successfully_created_bullet)
      redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
    else
      respond_with(@bullet)
      flash[:error] = t(:error_creating)
    end
    
  end
  
  def update
    if @bullet.update_attributes(params[:bullet])
      flash.notice = t(:successfully_updated_bullet)
      redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
    else
      respond_with(@bullet)
    end
  end

    
  def destroy
    if @bullet.destroy
      flash[:notice] = t(:successfully_removed_bullet)
    else
      flash[:error] = t(:error_deleting)
    end
    redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
  end
  
  private
  def load_parent
    @taxonomy = Spree::Taxonomy.find(params[:taxonomy_id])
    @taxon = @taxonomy.taxons.find(params[:taxon_id])
    @bullet = Spree::Bullet.find(params[:id]) if params[:id]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_category_bullets-0.0.2 app/controllers/spree/admin/bullets_controller.rb
spree_category_bullets-0.0.1 app/controllers/spree/admin/bullets_controller.rb