Module: Api::V2::TaxonomiesController

Extended by:
ActiveSupport::Concern
Included in:
LocationsController, OrganizationsController
Defined in:
app/controllers/concerns/api/v2/taxonomies_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


28
29
30
31
32
# File 'app/controllers/concerns/api/v2/taxonomies_controller.rb', line 28

def create
  @taxonomy = taxonomy_class.new(params[taxonomy_single.to_sym])
  instance_variable_set("@#{taxonomy_single}", @taxonomy)
  process_response @taxonomy.save
end

#destroyObject


42
43
44
# File 'app/controllers/concerns/api/v2/taxonomies_controller.rb', line 42

def destroy
  process_response @taxonomy.destroy
end

#indexObject


13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/concerns/api/v2/taxonomies_controller.rb', line 13

def index
  if @nested_obj
    #@taxonomies = @domain.locations.paginate(paginate_options)
    @taxonomies = @nested_obj.send(taxonomies_plural).search_for(*search_options).paginate(paginate_options)
  else
    @taxonomies = taxonomy_class.search_for(*search_options).paginate(paginate_options)
  end
  instance_variable_set("@#{taxonomies_plural}", @taxonomies)
  render 'api/v2/taxonomies/index'
end

#showObject


24
25
26
# File 'app/controllers/concerns/api/v2/taxonomies_controller.rb', line 24

def show
  render 'api/v2/taxonomies/show'
end

#updateObject


34
35
36
37
38
39
# File 'app/controllers/concerns/api/v2/taxonomies_controller.rb', line 34

def update
  # NOTE - if not ! and invalid, the error is undefined method `permission_failed?' for #<Location:0x7fe38c1d3ec8> (NoMethodError)
  # removed process_response & added explicit render 'api/v2/taxonomies/update'.  Otherwise, *_ids are not returned

  process_response  @taxonomy.update_attributes(params[taxonomy_single.to_sym])
end