Commit 1738f3c8 by Prem Sichanugrist

Add some more documentation for passing symbol to :url, :default_url, :path

parent 996ca871
......@@ -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
......
......@@ -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|
......
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