public
Fork of thoughtbot/paperclip
Description: Forked to store files in a database table
Homepage: http://patshaughnessy.net/paperclip-database-storage
Clone URL: git://github.com/patshaughnessy/paperclip.git
jyurek (author)
Tue Mar 18 15:51:56 -0700 2008
commit  0544f0f9e82144cf200f264ea59020a690d57a33
tree    6183d6978159130b136763367e2b51be56769372
parent  830c0aa8f9ea64b1d83127380f598a0fb780f143
name age message
file README Tue Mar 18 15:51:56 -0700 2008 Doc changes git-svn-id: https://svn.thoughtbot... [jyurek]
file Rakefile Thu Nov 15 12:15:55 -0800 2007 Validations work as expected with invalid image... [jyurek]
directory generators/ Fri Oct 26 09:16:58 -0700 2007 Did some APIish stuff. git-svn-id: https://svn... [jyurek]
file init.rb Fri Nov 09 08:17:58 -0800 2007 On the way to good-code-dom git-svn-id: https:... [jyurek]
directory lib/ Tue Mar 18 15:51:56 -0700 2008 Doc changes git-svn-id: https://svn.thoughtbot... [jyurek]
directory tasks/ Tue Mar 18 10:59:04 -0700 2008 Huge refactoring. git-svn-id: https://svn.thou... [jyurek]
directory test/ Tue Mar 18 10:59:04 -0700 2008 Huge refactoring. git-svn-id: https://svn.thou... [jyurek]
README
=Paperclip

Paperclip is intended as an easy file attachment library for ActiveRecord. The intent behind it was to keep setup as 
easy as possible and to treat files as much like other attributes as possible. This means they aren't saved to their 
final locations on disk, nor are they deleted if set to nil, until ActiveRecord::Base#save is called. It manages 
validations based on size and presence, if required. It can transform its assigned image into thumbnails if needed, and 
the prerequisites are as simple as installing ImageMagick (which, for most modern Unix-based systems, is as easy as 
installing the right packages). Attached files are saved to the filesystem and referenced in the browser by an easily 
understandable specification, which has sensible and useful defaults.

See the documentation for the +has_attached_file+ method for options.

==Usage

In your model:

  class User < ActiveRecord::Base
    has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
  end

In your edit and new views:

  <% form_for :user, @user, :url => user_path, :html => { :multipart => true } do |form| %>
    <%= form.file_field :avatar %>
  <% end %>

In your controller:

  def create
    @user = User.create( params[:user] )
  end

In your show view:

  <%= image_tag @user.avatar.url %>
  <%= image_tag @user.avatar.url(:medium) %>
  <%= image_tag @user.avatar.url(:thumb) %>