Class: Tasks::TaxonNames::SynchronizeOtusController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Tasks::TaxonNames::SynchronizeOtusController
- Includes:
- TaskControllerConfiguration
- Defined in:
- app/controllers/tasks/taxon_names/synchronize_otus_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET/POST (hack preview).
-
#synchronize ⇒ Object
POST.
Methods included from TaskControllerConfiguration
Instance Method Details
#index ⇒ Object
GET/POST (hack preview)
5 6 7 8 |
# File 'app/controllers/tasks/taxon_names/synchronize_otus_controller.rb', line 5 def index @taxon_name = TaxonName.where(project_id: sessions_current_project_id).find(params[:taxon_name_id]) if params[:taxon_name_id] @taxon_name ||= sessions_current_project.root_taxon_name end |
#synchronize ⇒ Object
POST
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/tasks/taxon_names/synchronize_otus_controller.rb', line 11 def synchronize @taxon_name = TaxonName.where(project_id: sessions_current_project_id).find(params[:taxon_name_id]) redirect_to synchronize_otus_to_nomenclature_task_path(taxon_name_id: @taxon_name.id), alert: "Please select a mode." and return if params[:mode].blank? if a = TaxonName.synchronize_otus(taxon_name_id: @taxon_name.id, mode: params.require(:mode)&.to_sym, user_id: sessions_current_user_id) redirect_to synchronize_otus_to_nomenclature_task_path(taxon_name_id: @taxon_name.id), notice: "Created #{a} OTUs" else redirect_to synchronize_otus_to_nomenclature_task_path, alert: 'Syncronization failed.' end end |