Class: Boss::ResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/boss/resources_controller.rb

Instance Method Summary collapse

Instance Method Details

#all_imagesObject



25
26
27
28
29
30
31
32
# File 'app/controllers/boss/resources_controller.rb', line 25

def all_images
  @images = Boss::Resource.all_images
  @images_json = @images.map do |image|
    { "thumb" =>image.resource.url, "image" => image.resource.url }
  end

  respond_with @images_json
end

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/boss/resources_controller.rb', line 5

def create
  if params[:type] == 'image'
    @resource = Boss::Resource.create_image params[:file]
    if @resource
      render text: { filelink: @resource.resource.url }.to_json
    else
      render status: 400
    end
  elsif params[:type] == 'file'
    @resource = Boss::Resource.create_file params[:file]
    if @resource
      render text: { filelink: @resource.resource.url, filename: @resource.resource_file_name }.to_json
    else
      render status: 400
    end
  else
    render status: 400
  end
end