paperclip
https://github.com/thoughtbot/paperclip
Ruby
Easy file attachment management for ActiveRecord
Paperclip::Attachment#initialize
Creates an Attachment object. +name+ is the name of the attachment,
+instance+ is the model object instance it's attached to, and
+options+ is the same as the hash passed to +has_attached_file+.
Options include:
+url+ - a relative URL of the attachment. This is interpolated using +interpolator+
+path+ - where on the filesystem to store the attachment. This is interpolated using +interpolator+
+styles+ - a hash of options for processing the attachment. See +has_attached_file+ for the details
+only_process+ - style args to be run through the post-processor. This defaults to the empty list (which is
a special case that indicates all styles should be processed)
+default_url+ - a URL for the missing image
+default_style+ - the style to use when an argument is not specified e.g. #url, #path
+storage+ - the storage mechanism. Defaults to :filesystem
+use_timestamp+ - whether to append an anti-caching timestamp to image URLs. Defaults to true
+whiny+, +whiny_thumbnails+ - whether to raise when thumbnailing fails
+use_default_time_zone+ - related to +use_timestamp+. Defaults to true
+hash_digest+ - a string representing a class that will be used to hash URLs for obfuscation
+hash_data+ - the relative URL for the hash data. This is interpolated using +interpolator+
+hash_secret+ - a secret passed to the +hash_digest+
+convert_options+ - flags passed to the +convert+ command for processing
+source_file_options+ - flags passed to the +convert+ command that controls how the file is read
+processors+ - classes that transform the attachment. Defaults to [:thumbnail]
+preserve_files+ - whether to keep files on the filesystem when deleting or clearing the attachment. Defaults to false
+filename_cleaner+ - An object that responds to #call(filename) that will strip unacceptable charcters from filename
+interpolator+ - the object used to interpolate filenames and URLs. Defaults to Paperclip::Interpolations
+url_generator+ - the object used to generate URLs, using the interpolator. Defaults to Paperclip::UrlGenerator
+escape_url+ - Perform URI escaping to URLs. Defaults to trueEdit
git clone [email protected]:thoughtbot/paperclip.git
cd paperclip
open lib/paperclip/attachment.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Paperclip--Attachment-initialize-for-pr
# Commit to gitgit add lib/paperclip/attachment.rbgit commit -m "better docs for Paperclip::Attachment#initialize"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Paperclip--Attachment-initialize-for-pr
hub pull-request
# Celebrate!