Class: Goldencobra::Api::V2::UploadsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/goldencobra/api/v2/uploads_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexjson

Returns:

  • (json)

    Liefert alle Uploads :id, :complete_list_name



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/goldencobra/api/v2/uploads_controller.rb', line 11

def index
  require "oj"

  @uploads = Goldencobra::Upload.
    order("image_file_name, updated_at DESC").
    select([:id, :image_file_name, :source, :rights, :updated_at])

  # Die React Select Liste braucht das JSON in diesem Format. -hf
  json_uploads = @uploads.map do |u|
    { "value" => u.id, "label" => u.complete_list_name }
  end

  respond_to do |format|
    format.json {
      render json: Oj.dump( { 'uploads' => json_uploads }, mode: :compat )
    }
  end
end