Class: Spree::Admin::BulletsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/bullets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/admin/bullets_controller.rb', line 15

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

#destroyObject



38
39
40
41
42
43
44
45
# File 'app/controllers/spree/admin/bullets_controller.rb', line 38

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

#indexObject



6
7
8
9
# File 'app/controllers/spree/admin/bullets_controller.rb', line 6

def index
  @bullets = Spree::Bullet.sorted_by_image_code.where(:taxon_id => @taxon.id)
  respond_with(:admin, @taxonomy, @taxon) 
end

#newObject



11
12
13
# File 'app/controllers/spree/admin/bullets_controller.rb', line 11

def new
  @bullet = Spree::Bullet.new(:taxon_id => @taxon.id, :is_active => true)
end

#updateObject



28
29
30
31
32
33
34
35
# File 'app/controllers/spree/admin/bullets_controller.rb', line 28

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