Class: Tasks::TaxonNames::SyncronizeOtusController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Tasks::TaxonNames::SyncronizeOtusController
- Includes:
- TaskControllerConfiguration
- Defined in:
- app/controllers/tasks/taxon_names/syncronize_otus_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET/POST (hack preview).
-
#syncronize ⇒ 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/syncronize_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 |
#syncronize ⇒ Object
POST
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/tasks/taxon_names/syncronize_otus_controller.rb', line 11 def syncronize @taxon_name = TaxonName.where(project_id: sessions_current_project_id).find(params[:taxon_name_id]) redirect_to syncronize_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.syncronize_otus(taxon_name_id: @taxon_name.id, mode: params.require(:mode)&.to_sym, user_id: sessions_current_user_id) redirect_to syncronize_otus_to_nomenclature_task_path(taxon_name_id: @taxon_name.id), notice: "Created #{a} OTUs" else redirect_to syncronize_otus_to_nomenclature_task_path, alert: 'Syncronization failed.' end end |