summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-14 20:44:48 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-14 20:44:48 +0000
commit4ebdcf13db34186bb562ed523c637dd6edc86682 (patch)
tree66be2cc4561468a6163202aa8b663954767727c3 /app/helpers
parentf607a7a023774362979ca5113a48e1138566b3bb (diff)
downloadredmine-4ebdcf13db34186bb562ed523c637dd6edc86682.tar.gz
redmine-4ebdcf13db34186bb562ed523c637dd6edc86682.zip
Add named routes for attachments and use route helpers in #link_to_attachment.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11187 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4825615a1..2a06ad926 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -91,14 +91,10 @@ module ApplicationHelper
# * :download - Force download (default: false)
def link_to_attachment(attachment, options={})
text = options.delete(:text) || attachment.filename
- action = options.delete(:download) ? 'download' : 'show'
- opt_only_path = {}
- opt_only_path[:only_path] = (options[:only_path] == false ? false : true)
- options.delete(:only_path)
- link_to(h(text),
- {:controller => 'attachments', :action => action,
- :id => attachment, :filename => attachment.filename}.merge(opt_only_path),
- options)
+ 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
# Generates a link to a SCM revision