Class: Tasks::Gis::OtuDistributionDataController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/gis/otu_distribution_data_controller.rb

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) show

GET /tasks/gis/otu_distribution_data?otu_id|taxon_name_id=123



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/tasks/gis/otu_distribution_data_controller.rb', line 5

def show
  @distribution = []
  if params[:otu_id]
    @otu = Otu.where(project_id: sessions_current_project_id).find(params[:otu_id])
  elsif params[:taxon_name_id]
    @taxon_name = TaxonName.where(project_id: sessions_current_project_id).find(params[:taxon_name_id])
  else
    @otu = Otu.where(project_id: sessions_current_project_id).first     
  end

  if @otu
    @distribution = Distribution.new(
      otus: Otu.where(id: @otu.id).where(project_id: sessions_current_project_id).page(params[:page])
    )
  elsif @taxon_name
    @distribution = Distribution.new(
      otus: Otu.for_taxon_name(@taxon_name).where(project_id: sessions_current_project_id).page(params[:page]).per(20)
    )
  else
    @distribution = []
  end
end