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
1738f3c8
Commit
1738f3c8
authored
Sep 23, 2011
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more documentation for passing symbol to :url, :default_url, :path
parent
996ca871
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
lib/paperclip.rb
+14
-0
lib/paperclip/interpolations.rb
+2
-1
No files found.
lib/paperclip.rb
View file @
1738f3c8
...
...
@@ -291,6 +291,20 @@ module Paperclip
# choices are :filesystem and :s3. The default is :filesystem. Make sure you read the
# documentation for Paperclip::Storage::Filesystem and Paperclip::Storage::S3
# for backend-specific options.
#
# It's also possible for you to dynamicly define your interpolation string for :url,
# :default_url, and :path in your model by passing a method name as a symbol as a argument
# for your has_attached_file definition:
#
# class Person
# has_attached_file :avatar, :default_url => :default_url_by_gender
#
# private
#
# def default_url_by_gender
# "/assets/avatars/default_#{gender}.png"
# end
# end
def
has_attached_file
name
,
options
=
{}
include
InstanceMethods
...
...
lib/paperclip/interpolations.rb
View file @
1738f3c8
...
...
@@ -25,7 +25,8 @@ module Paperclip
# Perform the actual interpolation. Takes the pattern to interpolate
# and the arguments to pass, which are the attachment and style name.
# You can pass a :symbol as pattern assigning some method in your model class.
# You can pass a method name on your record as a symbol, which should turn
# an interpolation pattern for Paperclip to use.
def
self
.
interpolate
pattern
,
*
args
pattern
=
args
.
first
.
instance
.
send
(
pattern
)
if
pattern
.
kind_of?
Symbol
all
.
reverse
.
inject
(
pattern
.
dup
)
do
|
result
,
tag
|
...
...
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