Class: Formstrap::MediaController
Instance Method Summary
collapse
Methods included from Pagination
#page, #paginate, #per_page
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/formstrap/media_controller.rb', line 19
def create
blobs = []
media_params[:files].reject { |c| c.blank? }.each do |file|
blobs << ActiveStorage::Blob.create_and_upload!(io: file, filename: file.original_filename)
end
respond_to do |format|
format.turbo_stream {
@blobs = blobs
}
format.html { redirect_to root_path }
end
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/formstrap/media_controller.rb', line 5
def index
blobs = ActiveStorage::Blob
blobs = filter(blobs)
blobs = sort(blobs)
blobs = blobs.group(:id)
@blobs = paginate(blobs)
@mimetypes = media_params[:mimetype]
respond_to do |format|
format.html
format.turbo_stream
end
end
|
#show ⇒ Object
33
34
35
|
# File 'app/controllers/formstrap/media_controller.rb', line 33
def show
@blob = ActiveStorage::Blob.find(params[:id])
end
|
#thumbnail ⇒ Object
37
38
39
|
# File 'app/controllers/formstrap/media_controller.rb', line 37
def thumbnail
@blob = ActiveStorage::Blob.find(params[:id])
end
|