Last Modified
2013-07-10 06:17:31 +0000
Requires
  • erb
  • tempfile
  • extlib
  • dm-core
  • dm-paperclip/upfile
  • dm-paperclip/iostream
  • dm-paperclip/geometry
  • dm-paperclip/processor
  • dm-paperclip/thumbnail
  • dm-paperclip/storage
  • dm-paperclip/interpolations
  • dm-paperclip/attachment
  • dm-validations
  • dm-paperclip/validations

Description

Paperclip allows file attachments that are stored in the filesystem. All graphical transformations are done using the Graphics/ImageMagick command line utilities and are stored in Tempfiles until the record is saved. Paperclip does not require a separate model for storing the attachment's information, instead adding a few simple columns to your table.

Author

Jon Yurek

Copyright

Copyright (c) 2008 thoughtbot, inc.

License

MIT License (www.opensource.org/licenses/mit-license.php)

Paperclip defines an attachment as any file, though it makes special considerations for image files. You can declare that a model has an attached file with the has_attached_file method:

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

user = User.new
user.avatar = params[:user][:avatar]
user.avatar.url
# => "/users/avatars/4/original_me.jpg"
user.avatar.url(:thumb)
# => "/users/avatars/4/thumb_me.jpg"

See the has_attached_file documentation for more details.