简体   繁体   中英

Rails4 | Paperclip: image is uploaded but it doesn't displays well (strange url is returned)

I'm using paperclip to upload images in rails, the images are saved well, but then, <%= @user.avatar.url %> returns this:

/system/users/avatars/000/000/001/original/1000203288934_DOCF635653TS102451125.gif%3F1416704056
/system/users/avatars/000/000/001/original/10407722_1175881652452049_8262371134443675175_n.jpg%3F1416705182

instead of just:

/system/users/avatars/000/000/001/original/1000203288934_DOCF635653TS102451125.gif
/system/users/avatars/000/000/001/original/10407722_1175881652452049_8262371134443675175_n.jpg

It happens for every image I upload. Where the hell that %3F-whatever at the end of the url comes from? What I'm doing wrong?

That is what Paperclip uses for cache-busting. If you want to remove it, just call @user.avatar.url(:original, timestamp: false)

You can also disable this globally by putting the following in the config/initializers/paperclip.rb file.

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

This answer explains why you may want cache-busting in place though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM