paperclip

Rails Paperclip: update vs. update_attributes

£可爱£侵袭症+ 提交于 2019-12-04 22:20:33
I realized something quite strange when attempting to upload an image via the paperclip gem for my user model (under the avatar attribute). For some reason there User.update and @user.update_attributes behaves differently. Does anyone know why this is so? #using @user.update_attributes(user_avatar_params) def update_profile_pic @user = User.find(params[:id]) @user.update_attributes(user_avatar_params) puts @user.avatar_file_name.nil? # prints false as expected respond_to do |format| format.html { redirect_to :back } format.js end end #using User.update(@user.id, user_avatar_params) def update

Completely stumped by “is not recognized by the 'identify' command” error in rails/paperclip on windows dev box

↘锁芯ラ 提交于 2019-12-04 20:26:12
Nothing I have tried seems to have any impact at all on this error. The code is working on both a Mac Pro dev maching as well as our Ubunto 9.10 server. Dev work is using Mongrel not Passenger. I am fully and completely stumped. Willing to try anything. I followed this: http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip to the letter. I tried installing both 32 and 64 bit versions (on XP 64). Updated config with: require "paperclip" Paperclip.options[:command_path] = 'C:\ImageMagick\ImageMagick-6.6.3-Q16' Paperclip.options[:swallow_stderr] = false System is: XP 64 bit

Resize Error - Paperclip::Errors::NotIdentifiedByImageMagickError

吃可爱长大的小学妹 提交于 2019-12-04 19:54:43
I just installed paperclip into my app to upload images, and everything was working well until I tried to add the styles to make the image resize. (I can upload images fine before I add this code) on pins.rb: has_attached_file :image, styles: { medium: "300x300>" } I then added the class to on _pin.html.rb: <td><%= image_tag pin.image(:medium) %></td> But now, when I try and upload an image, I get the error: Paperclip::Errors::NotIdentifiedByImageMagickError When I remove the styles, it works fine (alebit not resized), but something in the resizing is messing it all up. I tried different file

Status code 422 Unprocessable Entity - Paperclip, ImageMagick & Rails 3

倾然丶 夕夏残阳落幕 提交于 2019-12-04 19:41:44
I am not sure what's causing this and would love some insight: Started POST "/uploads.js" for 127.0.0.1 at 2011-02-21 09:14:36 -0500 Processing by UploadsController#create as JS Parameters: {"name"=>"DSC_0561.JPG", "chunk"=>"0", "chunks"=>"1", "upload"=>{"stage_id"=>"16"}, "authenticity_token"=>"SfNGZm4lP56eG94OliSo2Kk9Tikg+X2pHaGoRLdbUmg=", "file"=>#<ActionDispatch::Http::UploadedFile:0x000001080f7ce8 @original_filename="DSC_0561.JPG", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"DSC_0561.JPG\"\r\nContent-Type: application/octet

Rails Paperclip : Is there any option to save the uploaded file outside of the public folder?

馋奶兔 提交于 2019-12-04 19:05:18
I am using paperclip gem for uploading. And i want to save the uploaded file/image outside of the public folder. If you have any idea please share. Actually there is many. The 'public' option is just to be able to test easily. For your production server, paperclip gives three options: File Storage S3 Storage (via aws-sdk) Fog Storage File storage can be configured to go to any folder you want with something like: config.paperclip_defaults = { :path => "/yourfolder/:basename.:extension" } This can be overridden on the class itself if needed: has_attached_file :avatar, :path => "/yourotherfolder

Rails 3, Paperclip - Custom Interpolations

不羁的心 提交于 2019-12-04 18:41:19
问题 I've been having some troubles making custom Interpolation, gone through every example I could find on web, but no matter what I did, had no success. At the moment I have this: Model has_attached_file :photo, :path => ":rails_root/public/images/:img_name-:style.:extension", :styles => { :original => '100x100', :thumb => '30x30' } initializers/paperclip.rb Paperclip.interpolates :img_name do |attachment, style| attachment.instance.img_name end img_name is field populated in form on upload with

Paperclip + S3: Migrating existing files from one :path format to another

佐手、 提交于 2019-12-04 17:55:07
问题 I have a model with a avatar paperclip attach. It has now a plain standard path has_attached_file :avatar, :path => "/:id-:style-:filename" Which I need to move into an obfuscated one has_attached_file :avatar, :path => "/:id-:hash.:extension" :hash_secret => 'asecuresecret' Everything's working fine with new images, but how do I migrate the existing files stored in S3 to the new path format, ie rename them? I'm using paperclip 2.7 and Rails 3.2 Thanks !!! 回答1: This rake task should do the

Can not run 'rake paperclip:refresh:thumbnails CLASS=Spree::Image' in rails spree app console getting No Such Key

假装没事ソ 提交于 2019-12-04 16:23:45
I am trying to RAILS_ENV=production run rake paperclip:refresh:thumbnails CLASS=Spree::Image on my remote server in my current rails app directory, so I can refresh the spree images that I have uploaded in the past. I am using S3, my bucket is setup correctly as I can see each of my product's images in individual ID folders in my AWS S3 bucket. But each time I run the above command I get a 'No Such Key' Error when the rake is aborted. This command runs locally and works fine. (obviously without the RAILS_ENV=production locally) Ok so I wrote this question to answer it myself. I hope the

Multiple Paperclip default_urls

大城市里の小女人 提交于 2019-12-04 15:58:05
问题 I am using Paperclip to upload an image to my Project model and I want to have an array of default images (not depending on the style, but different images) is that posible? To pass an array instead of just one URL to the :default_url option? Thank you, Nicolás Hock Isaza 回答1: So close: If you want the images to change randomly, and not just on first load of the model: :default_url => lambda { "path/to/images/#{rand(5)}.jpg" } 回答2: Putting rand(5) in the default_url proc will assign a random

can you pass self to lambda in rails?

霸气de小男生 提交于 2019-12-04 15:46:51
I want to define a class method that has access to a local variable. So this would be different for each instance of the class. I know you can make a class method dynamic with lambda like when you use it with named_scope. But can this be done for values that are specific to an instance? In detail it is the has_attached_file method for the paperclip plugin in rails. I want to pass a lambda for the styles hash so that the image styles can be based off of attributes of the object stored in the DB. Is this possible? Disclaimer: First, the question ( Can you pass self to lambda? ) and the problem