paperclip

Define paperclip style sizes dynamicaly

泄露秘密 提交于 2019-12-11 07:14:36
问题 I have an application where a user chooses a template. On this template the user can upload an image. I use paperclip to upload the images. Each template has different image sizes. Is it possible to set an image style => 'widthxheight' dynamically in paperclip? I want this functionality because if the user decides to change template then they don't have to upload the photo again they just crop the 'original'. Thanks for any help. I will try to clear this up. A user uploads an image for the

rake paperclip:refresh not working on heroku

主宰稳场 提交于 2019-12-11 06:53:53
问题 I have changed my paperclip styles and want to refresh them on heroku. I do as heroku run rake --trace paperclip:refresh CLASS=VenueImage and get the error ** Invoke paperclip:refresh (first_time) ** Invoke paperclip:refresh:metadata (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute paperclip:refresh:metadata rake aborted! uninitialized constant VenueImage /app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing' /app/vendor

Rails, Paperclip not validating content type “application/octet-stream”?

送分小仙女□ 提交于 2019-12-11 06:14:41
问题 I'm using paperclip to upload files of the mime-type "application/octet-stream", but they aren't validating properly. In the controller, when I call replay.save! , I get the following error: Validation failed: r_file has contents that are not what they are reported to be, r_file is invalid, r_file content type is invalid Here is the model: class Replay < ApplicationRecord has_attached_file :r_file validates_attachment_content_type :r_file, content_type: { content_type: "application/octet

Paperclip: Cannot attach XLS (But DOC works)

元气小坏坏 提交于 2019-12-11 05:57:40
问题 I cannot attach a XLS file, but DOC works: Attachments file content type is invalid Attachments file is invalid Here is the log: Parameters: ... "files"=>[#<ActionDispatch::Http::UploadedFile:0x0000000daf7730 @tempfile=#<Tempfile:C:/Users/Chloe/AppData/Local/Temp/RackMultipart20170511-47156-ym774u.xls>, @original_filename="Chocolate_Store1.xls", @content_type="application/vnd.ms-excel", @headers="Content-Disposition: form-data; name=\"deal[files][]\"; filename=\"Chocolate_Store1.xls\"\r

Rails: How does MD5 checksum work in paperclip?

流过昼夜 提交于 2019-12-11 05:53:04
问题 I am really confused about this: from the officially paperclip wiki page: A MD5 checksum of the original file assigned will be placed in the model if it has an attribute named fingerprint. I have a attachment_fingerprint in my table and paperclip will insert the md5 value into that field automatically. The question is, how is the checksum generated? is it generated before the upload or after the upload? For example, the original file has a checksum 1 and the file get corrupted during the

How to watermark images using Imagemagick?

夙愿已清 提交于 2019-12-11 05:42:51
问题 I thought I'd add this, as it took me ages to get it working and I've seen loads of people having problems with it. I'm trying to add a watermark processor to the images model in a Spree (Rails) app. I was getting errors such as: There was an error processing the watermark for stream composite: unable to open image No such file or directory @ error/blob.c/OpenBlob/2588 @ error/png.c/ReadPNGImage/3633 PaperclipCommandNotFoundError PaperclipCommandLineError 回答1: I added the following to RAILS

Paperclip upload and showing the image not working

与世无争的帅哥 提交于 2019-12-11 05:40:25
问题 I installed paperclip -> 5.1 and latest ImageMagick on Windows 7(yeah..i know) running Ruby 2.3.3 and Rails 5.1.4. I installed file.exe as suggested by paperclip instructions and added 'C:\Program Files (x86)\GnuWin32\bin' to my PATH. When i upload my pictures i get the following error: ActionController::RoutingError (No route matches [GET] "/images/medium/missing.png"): and when i try to view the show page to see the images i get the following error: ActionController::RoutingError (No route

when to update record after save?

烂漫一生 提交于 2019-12-11 05:40:06
问题 I am using paperclip to attach files to a Model of mine. What I would like to do is, after the model has been saved and the file written to disk, I need to then update another attribute in my model about the file (a CRC). Since paperclip does not write the file to disk until after the .save has been called, my first thought was to use the after_save callback. When I do this, I get a "SystemStackError (stack level too deep):" error. Then I tried to do a after_commit callback which seems to be

Paperclip routing error

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:39:54
问题 After I register a user, the request goes through and says that the registration was successful, but instead of the resized image appearing, the file name is the only thing that appears. Here is my error message: Started GET "/system/photos/1/small/Picture%202.png?1312915420" for 127.0.0.1 at Tue Aug 09 16:14:01 -0400 2011 ActionController::RoutingError (No route matches "/system/photos/1/small/Picture%202.png"): 回答1: Maybe you need to change this line in config/environments/production.rb

paperclip images not saving in the path i've set up

一笑奈何 提交于 2019-12-11 05:04:40
问题 im tring to save the images I upload with paperclip to a specific path. I would like the Images to be saved in app/assets/image dir in the ruby on rails application, but they don't seem to go in there this is what the path looks like in the config/environments/development.rb config.paperclip_defaults = { :url => ":rails_root/app/assets/images/:attachment/:id/:style/:filename", :path => "/:class/:attachment/:id/:style/:basename.:extension" } I really appreciate any advice or help you can give