Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 33 lines (20 sloc) 1.408 kB
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
1 =Paperclip
13318e6 Initial version
jyurek authored
2
0544f0f Doc changes
jyurek authored
3 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.
13318e6 Initial version
jyurek authored
4
5494e3c Docs and some splitting up of files because the single one was annoying.
jyurek authored
5 See the documentation for the +has_attached_file+ method for options.
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
6
7 ==Usage
13318e6 Initial version
jyurek authored
8
9 In your model:
10
5494e3c Docs and some splitting up of files because the single one was annoying.
jyurek authored
11 class User < ActiveRecord::Base
2784b38 Huge refactoring.
jyurek authored
12 has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
13 end
13318e6 Initial version
jyurek authored
14
403e628 README update and default style
jyurek authored
15 In your edit and new views:
13318e6 Initial version
jyurek authored
16
5494e3c Docs and some splitting up of files because the single one was annoying.
jyurek authored
17 <% form_for :user, @user, :url => user_path, :html => { :multipart => true } do |form| %>
18 <%= form.file_field :avatar %>
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
19 <% end %>
13318e6 Initial version
jyurek authored
20
21 In your controller:
22
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
23 def create
2784b38 Huge refactoring.
jyurek authored
24 @user = User.create( params[:user] )
110df00 Extensive documentation, adding ability to crop thumbnails.
jyurek authored
25 end
403e628 README update and default style
jyurek authored
26
27 In your show view:
28
5494e3c Docs and some splitting up of files because the single one was annoying.
jyurek authored
29 <%= image_tag @user.avatar.url %>
30 <%= image_tag @user.avatar.url(:medium) %>
31 <%= image_tag @user.avatar.url(:thumb) %>
830c0aa Copy changes
jyurek authored
32
Something went wrong with that request. Please try again.