paperclip

Rails - Paperclip validating attachment size when it shouldn't be?

I've got a rails model using Paperclip that looks like this: has_attached_file :image, :styles => { :normal => ['857x392#', :png] }, :url => '/assets/pages/:id/:basename.:extension', :path => ':rails_root/public/assets/pages/:id/:basename.:extension' validates_attachment_size :image, :less_th...

Rails find - order by presence of Paperclip attachment then record creation datetime

I am building a gallery index of Items in which some Items have photos and others do not. I would like to grab all of the Items (or a subset with will_paginate) and sort them first by the items with a photo (attached via Paperclip) and then by the record creation date. I need a binary "has attachment" type status for the first part. Do...

Paperclip::NotIdentifiedByImageMagickError when file is not a valid attachment content type

Hi, I have systematically an error when I'm trying to upload a file that is not in ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"] When I try to upload a file like a wav I have this message * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'i...

Paperclip S3 download remote images

How I can download a remote image (http protocol, the url is in the image_remote_url attribute) and save it as an attachment to S3 via Paperclip ? class Product < ActiveRecord::Base require 'open-uri' attr_accessor :image_remote_url has_attached_file :photo, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml"...

Accelerate S3 upload with paperclip

I'm using paperclip for uploading images in S3. But I've noted that this upload is very slow. I think because before complete the submit the file has to pass by my server, be processed and be sent to the S3 server. Is there a method for accelerate this? thanks ...

Paperclip save images as jpg with white background

Hi, I'd like to know how to convert png and gif files with alpha channel to jpg with white background with paperclip I tried this but, it doesn't work has_attached_file :photo, :whiny => false, :styles => { :medium => ["300x300>", :jpg], :thumb => ["100x100>", :jpg] }, :convert_options => { :all => '-alpha white -background white'}...

Ror + Paperclip: Why not work?

I've installed paperclip to my project as plugin using ruby script/plugin install http://github.com/thoughtbot/paperclip.git Model: class Company < ActiveRecord::Base has_attached_file :logo, :styles => { :large => "300x300>", :medium => "100x100>", :thumb => "50x50>" } validates_attachment_content_type :logo, :content_type => im...

Rails Paperclip plugin - Validations

The rails plugin paperclip supports validations at the model such as: validates_attachment_size The only problem is that using this validation seems to force the validation of an actual attachment, where sometimes there may not be one. If I'm validating the following, what condition :if could I use to ignore the validation if there i...

Uploading images from Flex to Rails using Paperclip

Hi everyone, I'm looking for a way to upload images that were created in my flex app to rails. I've tried to use paperclip, but it don't seem to work. I've got this tutorial here: http://blog.alexonrails.net/?p=218 The problem is, that they are using a FileReference to browse for files on the clients computer. They call the .upload(.....

Rails Rake Tasks, output a message during and at the end.

Hi, I've made a rails rake task that uploads/crops/re-sizes (with paperclip) silly amounts of images. I wanted to know how to output a message to the terminal when it was running (e.g. chipolata.jpg processed) and at the end, it takes a good few minutes to run and a little feedback would be good. Thanks. ...

Rails: Paperclip & previews?

You know on some sites when you're asked to upload, say, an avatar, you click on the button, select your file, then hit OK, but before you Submit the page (as in, no record is created/updated), a little preview of the image shows up? How would I accomplish this using Paperclip for Rails? Bonus points for anyone who can point me towards...

Unit testing paperclip uploads with Rspec (Rails)

Total Rspec noob here. Writing my first tests tonight. I've got a model called Image. Using paperclip I attach a file called photo. Standard stuff. I've run the paperclip generator and everything works fine in production and test modes. Now I have a spec file called image.rb and it looks like this (it was created by ryanb's nif...

Smarter paperclip validations

I'm using paperclip in a rails app and have the following three validations in my model validates_attachment_presence :photo validates_attachment_size :photo, :less_than=>1.megabyte validates_attachment_content_type :photo, :content_type=>['image/jpeg', 'image/png', 'image/gif'] If the user forgets to add an attac...

WYSIWYG editor for Rails with Paperclip Integration

I'm looking for a way of integrating a WYSIWYG editor into my rails app so it will use Paperclip for Image / File uploads. What I want is this: User can use a WYSIWYG field to create some rich text. They can upload an image into this text but the image will be stored nicely in a DB (hopefully using something like Paperclip) instead of j...

How to disable postprocessing for pdf files in Paperclip?

Paperclip by default try to process every image file to generate thumbnail. But it also try to do it with pdf files, which can be really time consuming task. I tried looking on google and found one solution, but it changes Paperclip methods. How to disable pdf postprocessing in Paperclip without changing Paperclip sources? ...

paperclip polymorphic association and saving

I changed my photo.rb model to be polymorphic and be usable to all sorts of other models needing to save images and it works fine except I can't figure out how to save new attachments properly through the parent model. Any ideas? Do I have to approach this differently somehow? As, its also not getting the imageable_type...which i'll h...

Paperclip and Postgres

Hi, I have strange situation - when I'm trying to update model, that can contains attachment by Paperclip (I'm using postgres as db) with the following code I see errors: >> u.profile.avatar = nil => nil >> u.save! ActiveRecord::RecordInvalid: Avatar file size file size must be between 0 and 1048576 bytes. from /opt/local/lib/r...

Paperclip and xhr.sendAsBinary

Hi, I use paperclip to add a file to my model. I want to use the new feature of firefox 3.6, xhr.sendAsBinary, to send a file with an ajax request. Here is how I build my request : var xhr = new XMLHttpRequest(); xhr.open("POST", "/photos?authenticity_token=" + token + "&photo[name]=" + img.name ...

ROR- Step by step multiple images using Paperclip.

I have used the "tutorial" on here but for some reason it didn't work. Can anyone give me a step-by-step guide for setting up a multiple image form (upload) with other form elements ... Also another tutorial (a good one) may be provided. I only want to use the paperclip plugin. @Gordon Isnor: I have uploaded my current (noob) project...

Ruby on rails - Paperclip : Error with png files in production mode

Why do I have this error when I try to upload a png files in production mode? It works fine with jpg and gif files... [paperclip] An error was received while processing: #Paperclip::NotIdentifiedByImageMagickError: /tmp/s3,8354,0.png is not recognized by the 'identify' command.> ...