This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 7dd35f582260658ef44464142d3887a7f649ada0
tree 50b583804ffd966869fc6ba6ef78212a8bbb511c
parent c40d947e98fbb11c322a4db875ed4accd16c3947
tree 50b583804ffd966869fc6ba6ef78212a8bbb511c
parent c40d947e98fbb11c322a4db875ed4accd16c3947
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Fri May 02 13:34:39 -0700 2008 | [austin.bain] |
| |
LICENSE | Fri Apr 18 09:08:33 -0700 2008 | [jyurek] |
| |
README | Fri Apr 18 09:08:33 -0700 2008 | [jyurek] |
| |
Rakefile | Tue Jul 08 14:37:48 -0700 2008 | [jyurek] |
| |
generators/ | Thu Aug 21 08:02:32 -0700 2008 | [jyurek] |
| |
init.rb | Fri Apr 18 09:08:54 -0700 2008 | [jyurek] |
| |
lib/ | Thu Nov 13 08:38:44 -0800 2008 | [Steve] |
| |
tasks/ | Wed Nov 05 13:32:14 -0800 2008 | [jyurek] |
| |
test/ | Fri Nov 14 14:45:31 -0800 2008 | [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 migrations:
class AddAvatarColumsToUser < ActiveRecord::Migration
def self.up
add_column :users, :avatar_file_name, :string
add_column :users, :avatar_content_type, :string
add_column :users, :avatar_file_size, :integer
end
def self.down
remove_column :users, :avatar_file_name
remove_column :users, :avatar_content_type
remove_column :users, :avatar_file_size
end
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) %>




