paperclip

How do I pass a variable watermark path to a paperclip watermark processor?

社会主义新天地 提交于 2019-12-05 10:20:29
I have watermarks, galleries, and photos models. Gallery belongs_to Watermark Photo belongs_to Gallery class Photo < ActiveRecord::Base before_save :save_dimensions, :set_orientation belongs_to :gallery has_attached_file :image, :processors => [:watermark], :styles => { :thumbnail => ["80x80>"], :small => { :geometry => "200x200>", :watermark_path => "#{gallery.watermark.image.path(:small)}", :position => "Center" }, :medium => { :geometry => "400x400>", :watermark_path => "#{gallery.watermark.image.path(:medium)}", :position => "Center" }, :large => { :geometry => "600x600>", :watermark_path

PaperClip Error NotIdentifiedByImageMagickError when scaling images

北战南征 提交于 2019-12-05 09:23:06
问题 I have been banging my head against this for several days. Recently, my image uploader has stopped working properly. I have investigated several possibilities, but have none of the suggested solutions have worked in my case. The error message is: #<Paperclip::Errors::NotIdentifiedByImageMagickError:Paperclip::Errors::NotIdentifiedByImageMagickError> Here are the details: Mac OS X 10.8.3 ImageMagick 6.8.4-4 2013-03-29 libtool => /usr/bin/libtool Rails 3.2.13 Ruby 1.9.3p194 development.rb

Heroku ffmpeg buildpacks for video uploads

拜拜、爱过 提交于 2019-12-05 08:35:34
问题 Is there a proper way to get heroku ffmpeg installed and running so that my users can upload videos in my rails app? Tried the Heroku references on the topic which led to my app running the heroku error check logs page... I know there has to be some installation I have to pass but don't seems to find anything on it - Please help with links or ideas :) 回答1: users can upload videos We've had it working on Heroku before; we used paperclip-ffmpeg (which is now paperclip-av-transcoder) with the

Rails - building an absolute url in a model's virtual attribute without url helper

不羁岁月 提交于 2019-12-05 07:06:29
I have a model that has paperclip attachments. The model might be used in multiple rails apps I need to return a full (non-relative) url to the attachment as part of a JSON API being consumed elsewhere. I'd like to abstract the paperclip aspect and have a simple virtual attribute like this: def thumbnail_url self.photo.url(:thumb) end This however only gives me the relative path. Since it's in the model I can't use the URL helper methods, right? What would be a good approach to prepending the application root url since I don't have helper support? I would like to avoid hardcoding something or

Overriding content_type for Rails Paperclip plugin

谁都会走 提交于 2019-12-05 06:55:10
I think I have a bit of a chicken and egg problem. I would like to set the content_type of a file uploaded via Paperclip. The problem is that the default content_type is only based on extension, but I'd like to base it on another module. I seem to be able to set the content_type with the before_post_process class Upload < ActiveRecord::Base has_attached_file :upload before_post_process :foo def foo logger.debug "Changing content_type" #This works self.upload.instance_write(:content_type,"foobar") # This fails because the file does not actually exist yet self.upload.instance_write(:content_type

Rails - paperclip - Multiple photo upload not saving

江枫思渺然 提交于 2019-12-05 06:37:29
I'm trying to make a create product page in rails. This includes adding multiple images and text fields. I have one model for products and one for photos. I'm using the paperclip gem for photo upload. But I get no picture when I view product page. Photos are not being saved to database. P.S. I use HAML. app/views/products/show.html.haml %b Name = @product.name %br %b Description = @product.description %br - @product.photos.each do |photo| = image_tag photo.image.url app/controllers/products_controller class ProductsController < ApplicationController before_filter :require_login before_filter

Paperclip with S3 on Rails 3 / uninitialized constant AWS::S3::Connection

我与影子孤独终老i 提交于 2019-12-05 06:15:41
I'm trying to upload a file to s3 using paperclip and get this error when making a new object and referencing the variable: the aws-s3 gem is installed the s3.yml file has the correct credentials ie: a = Attachment.new a.file NameError: uninitialized constant AWS::S3::Connection from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing' from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:32 from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31:in `class_eval' from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31 from /Library/Ruby

NoMethodError: undefined method `has_attached_file'

*爱你&永不变心* 提交于 2019-12-05 06:07:35
Paperclip produces this error, after checking out the plugin's rails3 branch. My Gemfile has following line: gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3' And the error message is: NoMethodError: undefined method `has_attached_file' for #<Class:0x2a50530> Update 06-21-10: the thoughtbot version has been fixed. I had to add Paperclip::Railtie.insert to my application.rb at the end of class Application < Rails::Application to get it to work correctly. I have deleted my fork since the official repo is working. Hope that helps someone. You will also

Validating attachment contents on upload with Paperclip gem

半世苍凉 提交于 2019-12-05 04:57:55
Paperclip has validator methods for validating the presence, size, and content-type of files. But is there a way to validate the contents of the file before the record is saved? I tried doing validate :my_method and opening the file from [attachment].path in my_method , but of course that fails because the attachment hasn't been moved to its final resting place in the file system before the record is saved. Writing a custom Paperclip post-processor seemed like an option because it has access to the File object belonging to the attachment before the record is saved, but a failing processor won

Change error validation message in Paperclip

痴心易碎 提交于 2019-12-05 04:51:20
When you set a validation message in paperclip, such as validates_attachment_presence, :image, :message => 'xxxx' The custom message comes automatically prefixed with the name of the field, even though it has been overwritten with the :message . How do you totally override the message and make it totally custom? Edit: typo Not a real solution but a Easy one is to skip paperclip validation and write custom one. validate :check_content_type def check_content_type if !['image/jpeg', 'image/gif','image/png'].include?(self.image_content_type) errors.add_to_base("Image '#{self.image_file_name}' is