|
|
|
@ -126,7 +126,7 @@ module ApplicationHelper
|
|
|
|
|
# Options:
|
|
|
|
|
# * :text - Link text (default to attachment filename)
|
|
|
|
|
# * :download - Force download (default: false)
|
|
|
|
|
def link_to_attachment(attachment, options={})
|
|
|
|
|
def link_to_short_attachment(attachment, options={})
|
|
|
|
|
text = h(truncate(options.delete(:text) || attachment.filename, length: 25, omission: '...'))
|
|
|
|
|
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
|
|
|
|
|
html_options = options.slice!(:only_path)
|
|
|
|
@ -134,6 +134,18 @@ module ApplicationHelper
|
|
|
|
|
link_to text, url, html_options
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Generates a link to an attachment.
|
|
|
|
|
# Options:
|
|
|
|
|
# * :text - Link text (default to attachment filename)
|
|
|
|
|
# * :download - Force download (default: false)
|
|
|
|
|
def link_to_attachment(attachment, options={})
|
|
|
|
|
text = options.delete(:text) || attachment.filename
|
|
|
|
|
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
|
|
|
|
|
html_options = options.slice!(:only_path)
|
|
|
|
|
url = send(route_method, attachment, attachment.filename, options)
|
|
|
|
|
link_to text, url, html_options
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def link_to_attachment_img(attachment, options={})
|
|
|
|
|
text = options.delete(:text) || attachment.filename
|
|
|
|
|
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
|
|
|
|
|