paperclip

Duplicate column name error when running migration

隐身守侯 提交于 2019-12-03 14:04:31
Whenever I run a migration in my Rails app, I get an error from SQLite3: SQLite3::SQLException: duplicate column name: photo_file_name: ALTER TABLE "users" ADD "photo_file_name" varchar(255) I already have a "Add Photo to User" migration. Here it is: class AddAttachmentPhotoToUsers < ActiveRecord::Migration def self.up change_table :users do |t| t.has_attached_file :photo end end def self.down drop_attached_file :users, :photo end end And here is the user migration: class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :title t.string

Paper Clip failing to save attachment

微笑、不失礼 提交于 2019-12-03 13:36:57
I'm using Ruby 1.9 and Rails 2.3.4 with Paperclip gem to save attachments. and I followed tutorial by adding the proper migration, adding (has_attached_file :video) to the model, making the form (multipart) and adding <%= f.file_field :video %> to it... When I try to upload a file I look in the log and I see: [paperclip] Saving attachments. But the file isn't really uploaded and the extra fields that have been added by paperclip are all NULLs!! The fact that it's not throwing any error making me confused where to start looking for possible issues. I'm using MAC OSX Leopard, is it possible that

“missing required :bucket option” for Paperclip/S3

北城以北 提交于 2019-12-03 13:19:25
问题 In my Rails app I'm letting users upload an image when they create a "release", and it should upload directly to S3. I'm getting the following error in both development and production. EDIT: I should note that this error happens when trying to upload from the release edit page on form submit. ArgumentError in ReleasesController#update missing required :bucket option Rails.root: /Users/jasondemeuse/pressed I've done this before with no issues using Carrierwave, but can't figure out what I'm

With paperclip, how can I change the image location to a “:parent_model_id/:id” folder format?

爱⌒轻易说出口 提交于 2019-12-03 13:13:50
问题 Given that I have a Listing model that has many images and each image has one attachment , how can I have the listing_id be part of the folder structure? Like so: system/photos/[listing_id]/:id I know that using :id will output the id of the image record. Here's what I currently have: class Image < ActiveRecord::Base belongs_to :listing #Rails ActiveRecord Relation. An image belongs to a post. # paperclip data has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>"

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

喜夏-厌秋 提交于 2019-12-03 12:27:31
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 !!! stream7 This rake task should do the trick. I tried it with aws-sdk 1.5.2 and ruby 1.9.3p194. The new_key should map to your new paperclip

How Can I Trigger a Scanner from a Browser?

淺唱寂寞╮ 提交于 2019-12-03 12:06:44
问题 I have Fujitsu fi-6130 TWAIN / ISIS scanners that I'd like to trigger from a button in a jQuery Rails web page. Not only would I like to have the page tell the scanner to "go", I'd also like to upload the resulting file via Paperclip once the (single) page is scanned - ideally without requiring the user to navigate a file explorer widget to find the file manually. Each scanner is usb attached to a Windows XP desktop, though we may replace these call center desktops with Google Chrome OS. This

Why are RackMultipart* files persisting in my Rails /tmp directory?

江枫思渺然 提交于 2019-12-03 12:05:56
问题 I'm using Paperclip (2.3) to handle image uploads on a Rails 3.0.3 app running on Ubuntu. Paperclip is handling the uploads as advertised BUT the RackMultipart* files that are created in the application's /tmp folder persist -- that is, they simply accumulate rather than deleting themselves. I realize that I could use tmpreaper to delete old tmpfiles but I'd really like to find a more elegant (and scalable) solution. I had a previous issue with temp files (i.e. RackMultipart* files)

Rails 3, Paperclip - Custom Interpolations

二次信任 提交于 2019-12-03 12:02:04
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 the image. The error I get on upload is: Invalid argument - (C:/Users/.../stream20110410-384

Paperclipped on Heroku?

痴心易碎 提交于 2019-12-03 11:37:55
I was curious if anyone could get paperclipped working on Heroku without using S3. I'm assuming Heroku is a read-only system, but there must be some way to save images there. You can't write to Heroku's file system, so no, there is no way to save images the way you want. Your options are using a service like S3, or storing them in the database. I recommend using S3, because databases are not optimized for file storage. It's worth reading Heroku's documentation on file uploads . You may save images to the log and tmp directories. However, that's a horrible, horrible idea. If you git push heroku

paperclip callbacks or simple processor?

笑着哭i 提交于 2019-12-03 10:48:11
I wanted to run the callback after_post_process but it doesn't seem to work in Rails 3.0.1 using Paperclip 2.3.8. It gives an error: undefined method `_post_process_callbacks' for #<Class:0x102d55ea0> I want to call the Panda API after the file has been uploaded. I would have created my own processor for this, but as Panda handles the processing, and it can upload the files as well, and queue itself for an undetermined duration I thought a callback would do fine. But the callbacks don't seem to work in Rails3. after_post_process :panda_create def panda_create video = Panda::Video.create(