paperclip

How can I change the upload directory for paperclip on heroku to /tmp?

被刻印的时光 ゝ 提交于 2019-12-18 17:00:23
问题 I need to upload files and then parse them using paperclip? Currently it is uploaded in the /system folder, which isn't allowed in heroku. I don't need the uploads to be persistent...I parse it and then store them. So I'd like to be able to save into /tmp and then parse, and then let it get blown away later. Thoughts on how to do this (if I should do this)? 回答1: Heroku's docs say to use Tempfile. Well, it says in the doc: There are two directories that are writeable: ./tmp and ./log (under

How to use Seed data with Paperclip + S3

非 Y 不嫁゛ 提交于 2019-12-18 16:19:17
问题 I'm trying to seed my database with member profiles and also member profile pictures with S3 and paperclip but it doesn't seem to be working. I can create/edit existing members within the application to add pictures with paperclip + S3 and it works just fine but seeding it doesn't work. I have searched but can't find an answer. 回答1: I don't know what is your exact problem but you can try something like this in your seeds.rb file : u = User.new({:name => 'username', :email => 'user@name.fr'...

paperclip + ActionMailer - Adding an attachment?

。_饼干妹妹 提交于 2019-12-18 15:35:28
问题 I have a paperclip'd file that I want to add as an attachment to my email.... class UserMailer < ActionMailer::Base def XXXXXX_notification(record) @record = record attachments ??? How to add a paperclip file? mail( :to => "#{record.email}", :subject => "XXXXXXXX" ) end There seems to be nothing on the topic via google, if you have any ideas, I'd love to hear it :) Thanks UPDATE @comment.attachments.each do |a| tempfile = File.new("#{Rails.root.to_s}/tmp/#{a.attachment_file_name}", "w")

Cleaning up Paperclip error messages

坚强是说给别人听的谎言 提交于 2019-12-18 13:38:27
问题 Okay, so i've got paperclip working, and I'm trying to use the built in validator to make sure that the file uploaded Is an image Is not too big So I have this in the model, per the documentation: validates_attachment :avatar, :content_type => { :content_type => /image/ }, :size => { :in => 0..2.megabytes } However the error it shows in the view is this mess: I'd like it to be something a bit simpler, like "Avatar must be an image less than 2 megabytes" However, I can't see where to do this,

Paperclip attachments with dynamic style sizes from Model

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 13:35:40
问题 Using Rails 2, I try to separate different, dynamic image sizes trough another Model from the Paperclip-Model. My current approach, using a Proc, looks the following: class File < ActiveRecord::Base has_many :sizes, :class_name => "FileSize" has_attached_file( :attachment, :styles => Proc.new { |instance| instance.attachment_sizes } ) def attachment_sizes sizes = { :thumb => ["100x100"] } self.sizes.each do |size| sizes[:"#{size.id}"] = ["#{size.width}x#{size.height}"] end sizes end end class

Attachment_fu or Paperclip for Rails3

安稳与你 提交于 2019-12-18 13:12:36
问题 I have just upgraded to rails3 and when I installed my usual attachment_fu plugin failed. So I started googling it and although I did manage to find a rails3 version there seemed to be a lot more people talking about paperclip with rails3. So firstly what are the advantages of paperclip? Is there better support for rails3 with it? 回答1: Neither. Use carrierwave . To handle the file uploads, I’ve switched from Paperclip to CarrierWave. While Paperclip has (and continues) to serve me well in

Ruby on Rails 4 - Duplicate paperclip validation messages

不问归期 提交于 2019-12-18 12:55:09
问题 Is there any way to prevent validation messages appearing twice for Paperclip upload validations? Here is my model: has_attached_file :photo, :styles => { :thumb => "215x165" }, :default_url => "/images/:style/missing.png" validates_attachment :photo, :presence => true, :content_type => { :content_type => "image/jpg" }, :size => { :in => 0..0.5.megabytes } Here is my view: <% if @product.errors.any? %> <p>The following errors were found:</p> <ul> <% @product.errors.full_messages.each do

Paperclip - Validate File Type but not Presence

有些话、适合烂在心里 提交于 2019-12-18 12:35:26
问题 I am using paperclip to handle my file uploads, and in one situation I don't want the file to be mandatory. I do however want to make sure it is a specific file type when it is present. I have this: class TestModel < ActiveRecord::Base #stuff has_attached_file :sound #etc... validates_attachment_content_type :sound, :content_type => ['audio/mp3', 'application/x-mp3'] end And when I have no sound file present, it tells me it is not one of the valid content types. I've tried adding '' to the

Use single attachment for video/image in paperclip

為{幸葍}努か 提交于 2019-12-18 12:03:10
问题 I am using paperclip for uploading file ( video and images). Have used the same attachment(source) for both video and images. class Media < ActiveRecord::Base belongs_to :memory validates_attachment_presence :source validates_attachment_content_type :source, :content_type => ['video/mp4', 'image/png', 'image/jpeg', 'image/jpg', 'image/gif'] end Now I wanted to display different error messages in different cases. When uploading file is image type but not the jpg/png/jpeg/gif. When uploaded

Rails 3 - Amazon S3 Paperclip EU Problem

不打扰是莪最后的温柔 提交于 2019-12-18 11:30:24
问题 I'm using: Paperclip 2.3.16 Rails 3.0.9 Ruby 1.9.2 AWS - S3 0.6.2 I'm trying to use paperclip the upload to the EU (Ireland) based bucket. I have the following in my model: has_attached_file :image, :styles => { :grid => '90x128#', :list => '140x200#', :original => '400x548'}, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :url => 'flyers/:id/:style/:basename.:extension', :path => 'flyers/:id/:style/:basename.:extension', :bucket => 'fsight' In my environment.rb I have set