7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/downloadables_controller.rb', line 7
def show
item = LineItem.find(params[:id])
if(item.download_limit.nil? || (item.download_limit > 0))
item.decrement!(:download_limit) if (!item.download_limit.nil?)
filepath = ""
if !item.product.downloadables.empty?
filepath = item.product.downloadables.first.attachment.path
elsif !item.variant.downloadables.empty?
filepath = item.variant.downloadables.first.attachment.path
end
send_file filepath else
flash[:error] = "Reached download limit."
redirect_to order_url(item.order)
end
end
|