Sneaky Abstractions

Subscribe to my Feed, follow me on , recommend me on Working With Rails or see my code on GitHub

ActsAsFile: Simple file storage plugin

Posted on June 14, 2007 16:00 Tagged with acts_as_file, plugin, rails.

ActsAsFile will save files attached to a model in a specified directory on the file system. It will add validation errors on the model if the file can’t be saved. And.. I think that’s it. As I said, it’s simple, and I like simple. Read more about it here.

class UploadedFile < ActiveRecord::Base

  acts_as_file
  
  self.save_path = File.join(RAILS_ROOT, 'public', 'uploads')
  self.read_path = 'uploads'

end

This is your first class ticket to high speed action and you're in the driver's seat