Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
227d6a42
Commit
227d6a42
authored
Oct 27, 2011
by
Gabe Berke-Williams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape underscores.
parent
41f685f6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
README.md
+12
-12
No files found.
README.md
View file @
227d6a42
...
...
@@ -121,25 +121,25 @@ Usage
-----
The basics of paperclip are quite simple: Declare that your model has an
attachment with the has
_attached
_file method, and give it a name. Paperclip
attachment with the has
\_
attached
\
_
file method, and give it a name. Paperclip
will wrap up up to four attributes (all prefixed with that attachment's name,
so you can have multiple attachments per model if you wish) and give them a
friendly front end. The attributes are
`<attachment>_file_name`
,
`<attachment>_file_size`
,
`<attachment>_content_type`
, and
`<attachment>_updated_at`
.
Only
`<attachment>_file_name`
is required for paperclip to operate. More
information about the options to has
_attached
_file is available in the
information about the options to has
\_
attached
\
_
file is available in the
documentation of Paperclip::ClassMethods.
Attachments can be validated with Paperclip's validation methods,
validates
_attachment_presence, validates_attachment_content
_type, and
validates
_attachment
_size.
validates
\_
attachment
\_
presence, validates
\_
attachment
\_
content
\
_
type, and
validates
\_
attachment
\
_
size.
Storage
-------
The files that are assigned as attachments are, by default, placed in the
directory specified by the :path option to has
_attached
_file. By default, this
location is ":rails_root/public/system/:attachment/:id/:style/:filename". This
directory specified by the :path option to has
\_
attached
\
_
file. By default, this
location is ":rails
\
_
root/public/system/:attachment/:id/:style/:filename". This
location was chosen because on standard Capistrano deployments, the
public/system directory is symlinked to the app's shared directory, meaning it
will survive between deployments. For example, using that :path, you may have a
...
...
@@ -169,11 +169,11 @@ a set of styles for an attachment, by default it is expected that those
"styles" are actually "thumbnails". However, you can do much more than just
thumbnail images. By defining a subclass of Paperclip::Processor, you can
perform any processing you want on the files that are attached. Any file in
your Rails app's lib/paperclip_processors directory is automatically loaded by
your Rails app's lib/paperclip
\
_
processors directory is automatically loaded by
paperclip, allowing you to easily define custom processors. You can specify a
processor with the :processors option to has
_attached
_file:
processor with the :processors option to has
\_
attached
\
_
file:
has_attached_file :scan, :styles => { :text => { :quality => :better } },
has_attached
\
_file :scan, :styles => { :text => { :quality => :better } },
:processors => [:ocr]
This would load the hypothetical class Paperclip::Ocr, which would have the
...
...
@@ -222,8 +222,8 @@ are called before and after the processing of each attachment), and the
attachment-specific
`before_<attachment>_post_process`
and
`after_<attachment>_post_process`
. The callbacks are intended to be as close to
normal ActiveRecord callbacks as possible, so if you return false (specifically
-
returning nil is not the same) in a before
_ filter, the post processing step
will halt. Returning false in an after_ filter will not halt anything, but you
\-
returning nil is not the same) in a before
\
_
filter, the post processing step
will halt. Returning false in an after
\
_
filter will not halt anything, but you
can access the model and the attachment if necessary.
_NOTE: Post processing will not even
*start*
if the attachment is not valid
...
...
@@ -349,7 +349,7 @@ Now you don't have to remember to refresh thumbnails in production everytime you
Unfortunately it does not work with dynamic styles - it just ignores them.
If you already have working app and don't want
`rake paperclip:refresh:missing_styles`
to refresh old pictures, you need to tell
Paperclip about existing styles. Simply create paperclip_attachments.yml file by hand. For example:
Paperclip about existing styles. Simply create paperclip
\
_
attachments.yml file by hand. For example:
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => {:thumb => 'x100', :croppable => '600x600>', :big => '1000x1000>'}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment