attachment-fu

Being as DRY as possible in a Ruby on Rails App

I'm currently using the awesome attachment-fu plugin for a Rails app, but as a novice developer, I've never encountered a scenario like the one I've found myself in. Essentially, I'm using the attachment-fu plugin on two levels. The first is for user avatars in the user class. The second is to allow file attachments (PDFs, etc) in a mess...

Alter :path_prefix dynamically when calling has_attachment via Attachment Fu plugin

By default Attachment Fu stores uploaded files in "public/#{table_name}". I want to modify this to be something like "public/#{table_name}/#{site_id}", where site_id is a property of the model. Note that I've tried using self.site_id and both fail. has_attachment :storage => :file_system, :max_size => 25.megabytes, ...

How do you validate attachment_fu's image width and height?

I want to be able to validate the image is exactly a certain with or a certain height, or if it's square. In the validation block of the model that has_attachment, when I try to access image_size, width, or height, it always comes out as null. I also asked the question here if you want more details. ...

TypeError (Can't convert nil into String) With Attachment_Fu

I'm handling file attachments in my Rails app with Attachment_fu, which provides a public_filename method to retrieve a file's URL. I'm using it on a model called Cover, so if I want to call the URL of an uploaded cover image, in a view I would do: <%= image_tag(@cover.public_filename) %> This works just fine when the user has the app...

Why doesn't my upload from Flash to Rails & attachment_fu work (it has something to do with the content type)?

I am trying to upload a file from a flash widget to my rails application, which uses attachment_fu to handle uplaoded images. I am using flash to upload since it makes it easy to select and upload multiple files. However, I am getting this error when the rails controller tries to call save! on the newly created ActiveRecord object: Ac...

Rails: attachment_fu plugin, convert PDF uploads to image

Yo, I've got attachment_fu set up on my server, and it works just fine. My goal, however, is to be able to upload PDFs and have them convert to image (then use all the pre-built attachment_fu options like resize and thumb produce the desired images). What currently happens is that PDFs upload and remain PDFs, whereas images go through a...

saving files outside the public folder with attachment_fu in ruby on rails

Hi All, I'm using attachment_fu in a rails application to handle file uploads, and i want to save them in a directory in the root of the application called attachments. however, I cannot seem to make this plugin save a file in any other directory than public. Can anyone tell me how to do this? thx -C ...

attachment_fu: Don't reload thumbnails

Hi, I've got a nice little "photos" class that has attached images. When I go to the page to sort the photos' order, it iterates though each photo, sets the new "sort" value, and saves it. All good so far. Problem is, I've noticed this behavior is fairly slow. Turns out, attachment_fu reloads the thumbnail on every save - regardless of...

Rails user-conditional statement in model

I'm working on a Rails app using attachment_ fu and Amazon S3 storage. Is it possible to make the :s3_ access (a part of the has_attachment options) conditional based on a user input when creating the object. I would like the user to be able if to select if the attachment is authenticated-read or public-read. Is this possible and how w...

What is the best way to upload a file to another Rails application?

I 've researched and noticed that ActiveResource lack this functionality. So, what is the current state of the art when doing a file upload? One problem with Guillermo's approach is that the request has to be nested, like this: body = { :file => {:uploaded_data => File.open("#{RAILS_ROOT}/public/tmp/" + original_filename), :owner_id =>...

Attachment_Fu thumbnail width

Any ideas on how to get the width and height of the thumbnail image? photo.width returns the original photos width. I am storing the width of the thumbnail in the database, I'm just not sure how to access that object. Doesn't work: <%= image_tag photo.authenticated_s3_url(:medium), :width => photo.width, :he...

rails + attachment_fu: issue with files in directories

Hi, I use attachment_fu for my rails app. It's great for me. However, the designer who works with me complains about it because it saves files in different directory. She said that she can't handle those files efficiently with Photoshop as they are scattered. I tried to persuade her with the following reasons. We can avoid file name...

What is involved with changing attachment_fu's storage scheme?

I have a rails application that is using attachment_fu. Currently, it is using :file_system for storage, but I want to change it to :s3, to allow for better scaling as more files get uploaded. What is involved with this? I imagine that if I just switch the code to use :s3, all the old links will be broken. Do I need to just copy the e...

Attachment_fu failing to validate on update

I have been using attachment_fu on a project for a long time and all was fine but now as I am trying to bring the project up to rails 2.3.3 I am running into a strange bug that is driving me nuts. The Attachment, a logo in this case, validates correctly on create but does not fail validation on update. I have debugged it and it fails the...

Using attachment_fu, how do you edit an existing photo, update only thumbnails, and leave original unedited?

After a photo is uploaded and created using attachment_fu, is there a way to edit just the thumbnails and leave the original as it is? I understand how to do the resizing or cropping, but it's applying the edits to all of the thumbnails and the originals, which is how I'm sure attachment_fu was intended to work. For example, say in a p...

Why is attachment_fu updating every attachment instead of just the changed ones ?

I have a Property model with a has_many and accepts_nested_attributes_for on a Image model which uses attachment_fu. Updating a Property using the following code results in a database UPDATE for every single image (and each image thumbnail) no matter whether there were changes to it or not. properties_controller.rb def update @pr...

Rails plugin Attachment_fu on Windows

I'm having problem with Rails plugin attachment_fu. On every upload, I get validation error Size is not included in the list I'm currently using Rails 2.3.3 Ruby 1.8.6 The only thing I found about this problem is quite outdated discussion, which didn't help much. Is there any solution to this problem? I'm using attachment_fu, b...

Uploading a file to a directory outside of RAILS ROOT with attachment_fu

Hi all, I'm trying to use attachment_fu to upload files to a directory outside of the RAILS_ROOT. I want the files to be saved to ~/APP_NAME/uploads/ so that they can be approved/rejected before becoming publicly available. I've tried the following configuration for has_attachment: has_attachment :storage => :file_system, ...

Serving files over HTTPS dynamically based on request.ssl? with Attachment_fu

I see there is a :user_ssl option in attachment_fu which checks the amazon_s3.yml file in order to serve files via https:// In the s3_backend.rb you have this method: def self.protocol @protocol ||= s3_config[:use_ssl] ? 'https://' : 'http://' end But this then makes it serve ALL s3 attachments with SSL. I'd like to mak...

Is it an issue to create a directory for each file upload, in a web application on linux/unix?

Hi, I am doing file-upload for a web-application (running on unix/linux). I'm wondering if there would be a concern if I planned to create a new directory for each file upload? This is the out-of-the-box approach for the Ruby on Rails plugin "paperclip". I debating what the trade-offs are, or whether perhaps it's just not a concern, ...