Class: ActionBlocks::AttachmentsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/action_blocks/attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#downloadObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/action_blocks/attachments_controller.rb', line 5

def download
  model = ActionBlocks.find(params[:model_key])
  if model == nil
    raise RecordNotFound
  end
  id = params[:id]
  field = params[:field]
  record = model.active_model.find(id)
  attachment = record.send(field)
  begin
    send_data attachment.download
  rescue Module::DelegationError
    raise ActiveRecord::RecordNotFound
  end
end