Class: Panel::BlobsController

Inherits:
BaseController show all
Defined in:
app/controllers/com/panel/blobs_controller.rb

Constant Summary

Constants included from RailsCom::Application

RailsCom::Application::LOCALE_MAP

Instance Method Summary collapse

Methods included from RailsCom::Application

#current_title, #default_form_params, #default_params, #json_format?, #set_country, #set_flash, #set_locale, #set_timezone, #set_variant

Instance Method Details

#createObject



27
28
29
30
31
32
33
# File 'app/controllers/com/panel/blobs_controller.rb', line 27

def create
  @blob = ActiveStorage::Blob.create_and_upload!(io: blob_params[:io].tempfile, filename: blob_params[:io].original_filename)

  unless @blob.persisted?
    render :new, locals: { model: @blob }, status: :unprocessable_entity
  end
end

#destroyObject



35
36
37
# File 'app/controllers/com/panel/blobs_controller.rb', line 35

def destroy
  @blob.purge
end

#indexObject



5
6
7
8
9
10
# File 'app/controllers/com/panel/blobs_controller.rb', line 5

def index
  q_params = {}
  q_params.merge! params.permit(:id, :key, :filename, :content_type)

  @blobs = ActiveStorage::Blob.default_where(q_params).order(id: :desc).page(params[:page])
end

#newObject



23
24
25
# File 'app/controllers/com/panel/blobs_controller.rb', line 23

def new
  @blob = ActiveStorage::Blob.new(filename: '')
end

#showObject



12
13
# File 'app/controllers/com/panel/blobs_controller.rb', line 12

def show
end

#unattachedObject



15
16
17
18
19
20
21
# File 'app/controllers/com/panel/blobs_controller.rb', line 15

def unattached
  q_params = {}
  q_params.merge! params.permit(:id, :key, :filename, :content_type)

  @blobs = ActiveStorage::Blob.unattached.default_where(q_params).order(id: :desc).page(params[:page])
  render :index
end