This repository has been archived by the owner on Sep 9, 2019. It is now read-only.
forked from thoughtbot/paperclip
-
Notifications
You must be signed in to change notification settings - Fork 0
Easy file attachment management for ActiveRecord
License
njvitto/paperclip
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
=Paperclip Paperclip is a lightweight attachment manager for ActiveRecord. It saves and manages your attachments, be they images or Word Docs, with one line of code. You can automatically thumbnail images as they're uploaded, and you don't have to worry about installing any ruby-specific libraries. You don't have to worry about compiling headaches with RMagick, concurrency issues and race conditions with MiniMagick, or unsupported image types with ImageScience. All you need is a working Image- or GraphicsMagick installation -- the +convert+ command is all you need. Paperclip uses the filesystem to save your files. You specify a root that the files will be saved to, and, if you're attaching images, any other sizes they need to be converted to, and they'll all be saved to the right place when your object saves. See the documentation for the +has_attached_file+ method for extensive details. ==Usage In your model: class Photo < ActiveRecord::Base has_attached_file :image, :thumbnails => { :medium => "300x300>", :thumb => "100x100>" } end In your edit and new views: <% form_for :photo, @photo, :url => photo_path, :html => { :multipart => true } do |form| %> <%= form.file_field :image %> <% end %> In your controller: def create @photo = Photo.create( params[:photo] ) end In your show view: <%= image_tag @photo.image_url %> <%= image_tag @photo.image_url(:original) %> <%= image_tag @photo.image_url(:medium) %> <%= image_tag @photo.image_url(:thumb) %>
About
Easy file attachment management for ActiveRecord
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published