[英]image_tag not showing paperclip uploaded image
Hi i'm using paperclip to upload and save the company avatar on my app. 嗨,我正在使用回形针上载公司头像并保存在我的应用程序中。 This is how it looks on company model:
这是公司模型的外观:
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
I'm also using an initializer, paperclip.rb: 我还使用了一个初始化程序paperclip.rb:
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = {:provider => "Local", :local_root => "#{Rails.root}/public"}
Paperclip::Attachment.default_options[:fog_directory] = ""
Paperclip::Attachment.default_options[:fog_host] = "http://localhost:3000"
Images are saved correctly, but when i try to display them like this: 图像正确保存,但是当我尝试像这样显示它们时:
<%= image_tag @company.avatar.url(:thumb) %>
It only shows the name of the file and no image. 它仅显示文件名,没有图像。
The html looks like this: html看起来像这样:
<img alt="Mini cooper" src="http://localhost:3000/companies/avatars/000/000/003/thumb/mini-cooper.jpg%3F1416616058">
And if i take out the characters after .jpg like the following: 如果我取出.jpg之后的字符,如下所示:
http://localhost:3000/companies/avatars/000/000/003/thumb/mini-cooper.jpg
I see the image just fine. 我看到图像很好。 But the helper just builds the url with those extra characters.
但是帮助程序只是使用这些额外的字符来构建url。 Any ideas?
有任何想法吗?
Looks like your issue is related to a recent commit which doesn't properly escape the timestamp. 看来您的问题与最近提交有关,而该提交未能正确逃避时间戳。 A temporary workaround is to disable the timestamp while a fix is worked-out.
临时的解决方法是在解决问题时禁用时间戳。
For individual calls 对于个人电话
@company.avatar.url(:thumb, timestamp:false)
Or you can disable this globally but putting the following line within your config/initializers/paperclip.rb
file. 或者,您可以全局禁用此功能,但将以下行放入
config/initializers/paperclip.rb
文件中。
Paperclip::Attachment.default_options[:use_timestamp] = false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.