Class: Tenon::AssetsController
Instance Method Summary
collapse
#create, #destroy, #index, #new, #reorder
Instance Method Details
#crop ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/tenon/assets_controller.rb', line 40
def crop
@asset = Asset.find(params[:id])
authorize @asset, :update?
render layout: false
end
|
#edit ⇒ Object
3
4
5
6
|
# File 'app/controllers/tenon/assets_controller.rb', line 3
def edit
super
render layout: false
end
|
#update ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/tenon/assets_controller.rb', line 8
def update
if resource_params[:duplicate] == '1'
@asset = Asset.find(params[:id])
new_asset = Asset.new(resource_params)
authorize(new_asset)
new_asset.attachment = @asset.attachment
new_asset.save
new_asset.crop_x = nil
working_asset = new_asset
else
working_asset = Asset.find(params[:id])
authorize(working_asset)
working_asset.update_attributes(resource_params)
end
working_asset.attachment.reprocess! if working_asset.cropping?
@asset = working_asset.decorate
self.resource = @asset
respond_to do |format|
format.html do
if @asset.valid?
redirect_to after_update_path
else
render action: :edit
end
end
format.json do
render json: @asset
end
end
end
|