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

I wish that they'd swoop down in the country lane, late at night when I'm driving, take me on board their beautiful ship, show me the world as I'd love to see it