Class: Admin::BaitLibraries::BaitLibraryTypesController

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

Instance Method Summary collapse

Instance Method Details

#createObject


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 14

def create
  @bait_library_type = BaitLibraryType.new(params[:bait_library_type])

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

#destroyObject


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

def destroy
  if @bait_library_type.bait_libraries.visible.count > 0
    respond_to do |format|
      flash[:error] = "Can not delete '#{@bait_library_type.name}', bait library type is in use by #{@bait_library_type.bait_libraries.visible.count} libraries."
      format.html { redirect_to(admin_bait_libraries_path) }
    end
  else
    respond_to do |format|
      if @bait_library_type.hide
        flash[:notice] = 'Bait Library Type was successfully deleted.'
      end
      format.html { redirect_to(admin_bait_libraries_path) }
    end
  end
end

#editObject


11
12
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 11

def edit
end

#newObject


7
8
9
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 7

def new
  @bait_library_type = BaitLibraryType.new
end

#updateObject


27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 27

def update
  respond_to do |format|
    if @bait_library_type.update(params[:bait_library_type])
      flash[:notice] = 'Bait Library Type was successfully updated.'
      format.html { redirect_to(admin_bait_libraries_path) }
    else
      format.html { render action: 'edit' }
    end
  end
end