Vote #73623
未完了url for thubms attachments ignores :only_path
0%
説明
My thumbs attachments url are being generated like this http://buck-assets-production.s3.amazonaws.com/attachments/thumbnail/"
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
this line have a "!" on end of slice
html_options = options.slice!(:only_path)
should not be without "!" ?
html_options = options.slice(:only_path)
journals
So the problemn is the image_tag that concats ActionController::Base.asset_host to thumbs url
<pre>
def thumbnail_tag(attachment)
link_to image_tag(thumbnail_path(attachment)),
named_attachment_path(attachment, attachment.filename),
:title => attachment.filename
end
</pre>
the correct one should be
<pre>
def thumbnail_tag(attachment)
image_tag = tag(:img, :src =>thumbnail_path(attachment), :alt => attachment.filename)
link_to image_tag,
named_attachment_path(attachment, attachment.filename),
:title => attachment.filename
end
</pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
It seems that AttachmentHelper#link_to_attachment works correctly. In the trunk r21049, @application_helper_test.rb@ with the following patch does not fail.
<pre><code class="diff">
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 730023443..e50f1ad1e 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1746,6 +1746,9 @@ class ApplicationHelperTest < Redmine::HelperTest
assert_equal(
'<a href="http://test.host/attachments/3">logo.gif</a>',
link_to_attachment(a, :only_path => false))
+ assert_equal(
+ '<a href="/attachments/3">logo.gif</a>',
+ link_to_attachment(a, :only_path => true))
end
def test_thumbnail_tag
</code></pre>
--------------------------------------------------------------------------------