以User Avatar头像为例:

1. Gemfile加入

gem 'paperclip', :git => "git://github.com/thoughtbot/paperclip.git"

2. model/user.rb加入

has_attached_file :avatar, :styles => {:large=>"200x200#",:normal=>"100x100#", :medium => "50x50#", :mini => "25x25#" }, :default_url => ":style/avatar_missing.png"

  validates_attachment :avatar,
                       :content_type => { :content_type => ["image/jpeg", "image/gif", "image/png"] },size: { in: 0..800.kilobytes }  

3.创建数据库迁移

rails generate paperclip user avatar

bin/rake db:migrate

4. 使用

<%= image_tag resource.avatar.url(:normal) %>