paperclip

rails: running a method on create only

I want to run a paperclip method on create only has_attached_file :file This method doesn't seem to accept the :on => :create that some other rails methods do. I tried: before_create after_create etc, but those didn't work. I also did: if :create How can I test if the controller is using the create method from the model? Than...

How do you create a sharesystem between two nodes in a cluster for a Rails app?

I deployed to a cluster, and realized that each node holds its own independant database. I am currently using Engine Yard as my host. How can I create a sharesystem so that all my nodes/instances share the same file system? Some people recommend S3, but this may not be the best choice because my users need to be able to edit their fil...

Resize existing images to new style in paperclip & RMagick

I've been using paperclip to upload and auto-resize photos in my Rails app, and I love it. Only problem is about every other month my crazy manager decides he wants a new size to display the photos in. So I add a new style in my Photo model and all is good for new photos, but the pre-existing photos are now a problem. Now that I'm starti...

Polymorphic Paperclip Interpolations

I'm using the Polymorphic fork of Paperclip in Rails, but have been having some massive problems with regards to the overwriting of unique filenames. No matter whether I put a time-stamp (more on that in a second) or the id of the asset in the URL, if a file with the same name is uploaded subsequently, then the previous one is overwritte...

Paperclip not showing on the edit page

I am having some issues with paperclip, on my new page, I have a paperclip file that relates to aonther model. If I don't upload the keynote at the time of creating I can't go back and edit it on the edit page, I'm pretty sure its something todo with the fact that its related to another model. Here is my form partial <% form_for([@proj...

Word,PDF Upload using Rails

I would like to know, how to upload documents like word, pdf using Rails. Can I use paperclip for it? ...

rails 3 paperclip imagemagick problem

I have been trying to get paperclip working for a few days now with no luck! From what I am aware this error below is related to imagemagick. I have tried to uninstall and install imagemagick both with macports and manually. Also, have Paperclip.options[:command_path] = "/usr/local/bin" set. It's starting to drive me nuts! Photo /var/fo...

how do I base encode a binary file (JPG) in ruby

I have a binary files which needs to be sent as a string to a third-party web-service. Turns out it requires that it needs to be base64 encoded. In ruby I use the following: body = body << Base64.b64encode(IO.read("#{@postalcard.postalimage.path}")) body is a strong which conists of a bunch of strings as parameters. Does this...

paperclip plugin not support for I18n

I've added I18n support for error messages: Now you can define translations for the errors messages in e.g. your YAML locale file: en: paperclip: errors: attachment: size: "Invalid file size" content_type: "Unsupported content type" presence: "Cant' be blank" when I use validates_attachemnt_zie :a...

rails paperclip problem when loading models in migrations

i get rake migrate errors when trying to load a model in migration files that has paperclip associations like: has_attached_file def self.up add_column :users, :events_count, :integer, :default => 0 u = User.find(:first) u.update_attribute :events_count, u.events.length end The User model has a paperclip association: "has_attac...

Trying to get paperclip to refresh or reprocess..

I have over time, changed the size for thumbs of the class Deal. Through these changes, users were uploading to the site, so there are few people who have different sized thumbs. I wanted to reprocress or refresh these, so I went to into my root and typed: $> rake paperclip:refresh class=Deal Did nothing for the thumb sizes.. Then I i...

Help on using paperclip plugin

I've just installed this plugin, created the migrations, added everything I needed to make it work(I didn't install ImageMagick yet). The problem is when I get the upload control parameter to save it in my controller, I get something like this: #<File:C:\Users\Brian\AppData\Local\Temp\RackMultipart.2560.6677> instead of a simple stri...

Shoulda and Paperclip testing

I am trying to test a couple models that have an attachment with Paperclip. I have all of my validations passing except for the content-type check. # myapp/test/unit/project_test.rb should_have_attached_file :logo should_validate_attachment_presence :logo should validate_attachment_size(:logo).less_than(1.megabyte) should_validate_atta...

Paperclip + ImageMagick on Windows 7: Image display fails when I add styles to attached_file in model

I'm working with Ruby on rails 2.3.8, NetBeans IDE. I've installed paperclip and I could show/save images successfully. Now, I've installed ImageMagick-6.6.2-4-Q16(for windows 7, 64bits). Until that moment, my model looked like this(and worked fine): has_attached_file :photo Now, after installing ImageMagick, when I add the :style l...

Paperclip and Amazon S3 Issue

Hey everyone, I have a rails app running on Heroku. I am using paperclip for some simple image uploads for user avatars and some other things, I have S3 set as my backend and everything seems to be working fine except when trying to push to S3 I get the following error: The AWS Access Key Id you provided does not exist in our records...

How do I install forked gems on heroku?

I'm trying to get Heroku working with European buckets on amazon s3 webserivces using the aws-s3 gem. It seems I need to install a forked version of the gem to get around the issue. However, with heroku I can only use the .gems file to install gems. Can I use this .gems file to install forked-gems somehow? ...

paperclip overwrites / resets S3 permissions for non-bucket-owners

I have opened this as an issue on Github (http://github.com/thoughtbot/paperclip/issues/issue/225) but on the chance that I'm just doing this wrong, I thought I'd also ask about it here. If someone can tell me where I'm going wrong, I can close the issue and save the Paperclip guys some trouble. Issue: When using S3 for storage, and y...

Update paths of already-created Paperclip attachments

I used to have this buggy Paperclip config: class Photo < ActiveRecord::Base has_attached_file :image, :storage => :s3, :styles => { :medium => "600x600>", :small => "320x320>", :thumb => "100x100#" }, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:file...

Conditional path names in Paperclip

I'm using this Paperclip configuration: has_attached_file :image, :storage => :s3, :styles => { :medium => "600x600>", :small => "320x320>", :thumb => "100x100#" }, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:filename" This gives me nice-looking pat...

Rails Paperclip Plugin - Style Options for Resizing

So, I want to resize images to a FIXED width, but proportional height. I have been trying a wide range of operators: 380x242# 380x242> 380!x242 380x242< none of them have the desired effect. Any help? I want it to fill or resize to the 380 width, then resize / shrink the height by the same factor it used to shrink or resize the image...