40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cms/attachments/attachment_serving.rb', line 40
def self.send_attachment(attachment, controller)
style = controller.params[:style]
style = "original" unless style
path_to_file = attachment.path(style)
if File.exists?(path_to_file)
Rails.logger.debug "Sending file #{path_to_file}"
controller.send_file(path_to_file,
:filename => attachment.file_name,
:type => attachment.file_type,
:disposition => "inline"
)
else
msg = "Couldn't find file #{path_to_file}'"
Rails.logger.error msg
raise ActiveRecord::RecordNotFound.new(msg)
end
end
|