Class: PlateTemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PlateTemplatesController
- Defined in:
- app/controllers/plate_templates_controller.rb
Constant Summary
Constants included from FlashTruncation
FlashTruncation::STRING_OVERHEAD
Instance Method Summary collapse
-
#create ⇒ Object
rubocop:todo Metrics/AbcSize.
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#update ⇒ Object
rubocop:todo Metrics/AbcSize.
Methods inherited from ApplicationController
#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
Methods included from FlashTruncation
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#create ⇒ Object
rubocop:todo Metrics/AbcSize
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/plate_templates_controller.rb', line 28 def create # rubocop:todo Metrics/AbcSize if params[:name].blank? flash[:error] = 'Please enter a name' redirect_to new_plate_template_path return end pattern = PlateTemplate.new pattern.update_params!( name: params[:name], user_id: current_user.id, wells: params[:empty_well], rows: params[:rows], cols: params[:cols] ) flash[:notice] = 'Template saved' redirect_to plate_templates_path end |
#destroy ⇒ Object
60 61 62 63 64 65 |
# File 'app/controllers/plate_templates_controller.rb', line 60 def destroy pattern = PlateTemplate.find(params[:id]) pattern.destroy respond_to { |format| format.html { redirect_to(plate_templates_path) } } end |
#edit ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/plate_templates_controller.rb', line 23 def edit @pattern = PlateTemplate.find(params[:id]) @plate_rows = Map::Coordinate.plate_length(@pattern.size) @plate_cols = Map::Coordinate.plate_width(@pattern.size) end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/plate_templates_controller.rb', line 8 def index @patterns = PlateTemplate.paginate(page: params[:page], per_page: 50) end |
#new ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/plate_templates_controller.rb', line 12 def new @plate_rows = params[:rows].to_i @plate_cols = params[:cols].to_i @plate_rows = Map::Coordinate.plate_length(96) if @plate_rows == 0 @plate_cols = Map::Coordinate.plate_width(96) if @plate_cols == 0 respond_to do |format| format.html # new.html.erb end end |
#update ⇒ Object
rubocop:todo Metrics/AbcSize
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/plate_templates_controller.rb', line 47 def update # rubocop:todo Metrics/AbcSize pattern = PlateTemplate.find(params[:id]) pattern.update_params!( name: params[:name], user_id: current_user.id, wells: params[:empty_well], rows: params[:rows], cols: params[:cols] ) flash[:notice] = 'Template updated' redirect_to plate_templates_path end |