Commit 0544f0f9 by jyurek

Doc changes

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@395 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent 830c0aa8
=Paperclip =Paperclip
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 requires. It can transform its assigned image into thumbnails if needed, and the setup for that is 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. 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.
See the documentation for the +has_attached_file+ method for options. See the documentation for the +has_attached_file+ method for options.
......
...@@ -31,6 +31,7 @@ require 'paperclip/geometry' ...@@ -31,6 +31,7 @@ require 'paperclip/geometry'
require 'paperclip/thumbnail' require 'paperclip/thumbnail'
require 'paperclip/attachment' require 'paperclip/attachment'
# The base module that gets included in ActiveRecord::Base.
module Paperclip module Paperclip
class << self class << self
# Provides configurability to Paperclip. There are a number of options available, such as: # Provides configurability to Paperclip. There are a number of options available, such as:
...@@ -136,9 +137,10 @@ module Paperclip ...@@ -136,9 +137,10 @@ module Paperclip
end end
# Places ActiveRecord-style validations on the size of the file assigned. The # Places ActiveRecord-style validations on the size of the file assigned. The
# possible options are :in, which takes a Range of bytes (i.e. +1..1.megabyte+), # possible options are:
# :less_than, which is equivalent to :in => 0..options[:less_than], and # * +in+: a Range of bytes (i.e. +1..1.megabyte+),
# :greater_than, which is equivalent to :in => options[:greater_than]..Infinity # * +less_than+: equivalent to :in => 0..options[:less_than]
# * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
def validates_attachment_size name, options = {} def validates_attachment_size name, options = {}
@attachment_definitions[name][:validations] << lambda do |attachment, instance| @attachment_definitions[name][:validations] << lambda do |attachment, instance|
unless options[:greater_than].nil? unless options[:greater_than].nil?
......
module Paperclip module Paperclip
# The Attachment class manages the files for a given attachment. It saves when the model saves,
# deletes when the model is destroyed, and processes the file upon assignment.
class Attachment class Attachment
attr_reader :name, :instance, :file, :styles, :default_style attr_reader :name, :instance, :file, :styles, :default_style
......
module Paperclip module Paperclip
# Handles thumbnailing images that are uploaded.
class Thumbnail class Thumbnail
attr_accessor :file, :current_geometry, :target_geometry, :format, :whiny_thumbnails attr_accessor :file, :current_geometry, :target_geometry, :format, :whiny_thumbnails
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment