2
votes

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::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:

<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:

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. Any ideas?

1
hi! same problem after update rails admin and paperclip. previous project with same gem list(but older gem version) work fine and opened correctly,with this charaterskpblc

1 Answers

0
votes

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.

Paperclip::Attachment.default_options[:use_timestamp] = false