Class: Backend::ImagesController
Instance Method Summary
collapse
#breadcrumb, #current_admin, #default_app_locale, #translate_notice
#crypt
Instance Method Details
#create ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/backend/images_controller.rb', line 11
def create
@image.build_asset
@image.asset.filename = params[:image][:asset][:filename]
@image.asset.description = params[:image][:asset][:description]
if @image.asset.filename && @image.asset.filename.content_type.to_s.include?('image') && @image.save
redirect_images_overview(:added)
else
@image.errors.add :filename, 'Ignore me'
render :new
end
end
|
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/backend/images_controller.rb', line 6
def index
@search = Asset.ransack params[:q]
@assets = @search.result(distinct: true).image.where.not(id: @model.images.pluck(:asset_id)).order('id DESC').limit(30)
end
|
#link ⇒ Object
24
25
26
27
|
# File 'app/controllers/backend/images_controller.rb', line 24
def link
@model.images.create(asset: Asset.find(params[:asset_id]))
redirect_images_overview(:added)
end
|
#unlink ⇒ Object
29
30
31
32
|
# File 'app/controllers/backend/images_controller.rb', line 29
def unlink
@model.images.find_by(asset_id: params[:asset_id]).destroy
redirect_images_overview(:deleted)
end
|