Class: Admin::BaitLibraries::BaitLibraryTypesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::BaitLibraries::BaitLibraryTypesController
- Defined in:
- app/controllers/admin/bait_libraries/bait_library_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 15 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 |
#destroy ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 39 def destroy usage_count = @bait_library_type.bait_libraries.visible.count if usage_count > 0 name = @bait_library_type.name flash[:error] = "Can not delete '#{name}', bait library type is in use by #{usage_count} libraries." else @bait_library_type.hide flash[:notice] = 'Bait Library Type was successfully deleted.' end redirect_to(admin_bait_libraries_path) end |
#edit ⇒ Object
12 13 |
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 12 def edit end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 8 def new @bait_library_type = BaitLibraryType.new end |
#update ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb', line 28 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 |