Class: Admin::BaitLibraries::BaitLibrarySuppliersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb', line 12

def create
  @bait_library_supplier = BaitLibrary::Supplier.new(bait_library_supplier_params)

  respond_to do |format|
    if @bait_library_supplier.save
      flash[:notice] = 'Supplier was successfully created.'
      format.html { redirect_to(admin_bait_libraries_path) }
    else
      format.html { render action: 'new' }
    end
  end
end

#destroyObject


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb', line 36

def destroy
  if @bait_library_supplier.bait_libraries.visible.count > 0
    respond_to do |format|
      flash[:error] = "Can not delete '#{@bait_library_supplier.name}', supplier is in use by #{@bait_library_supplier.bait_libraries.visible.count} libraries.<br/>"
      format.html { redirect_to(admin_bait_libraries_path) }
    end
  else
    respond_to do |format|
      if @bait_library_supplier.hide
        flash[:notice] = 'Supplier was successfully deleted.'
      end
      format.html { redirect_to(admin_bait_libraries_path) }
    end
  end
end

#editObject


9
10
# File 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb', line 9

def edit
end

#newObject


5
6
7
# File 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb', line 5

def new
  @bait_library_supplier = BaitLibrary::Supplier.new
end

#updateObject


25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb', line 25

def update
  respond_to do |format|
    if @bait_library_supplier.update(bait_library_supplier_params)
      flash[:notice] = 'Supplier was successfully updated.'
      format.html { redirect_to(admin_bait_libraries_path) }
    else
      format.html { render action: 'edit' }
    end
  end
end