Method: Paperclip::Attachment#url
- Defined in:
- lib/paperclip/attachment.rb
#url(style_name = default_style, options = {}) ⇒ Object
Returns the public URL of the attachment with a given style. This does not necessarily need to point to a file that your Web server can access and can instead point to an action in your app, for example for fine grained security; this has a serious performance tradeoff.
Options:
timestamp
- Add a timestamp to the end of the URL. Default: true. escape
- Perform URI escaping to the URL. Default: true.
Global controls (set on has_attached_file):
interpolator
- The object that fills in a URL pattern’s variables. default_url
- The image to show when the attachment has no image. url
- The URL for a saved image. url_generator
- The object that generates a URL. Default: Paperclip::UrlGenerator.
As mentioned just above, the object that generates this URL can be passed in, for finer control. This object must respond to two methods:
#new(Paperclip::Attachment, options_hash) #for(style_name, options_hash)
143 144 145 146 147 148 149 |
# File 'lib/paperclip/attachment.rb', line 143 def url(style_name = default_style, = {}) if == true || == false # Backwards compatibility. @url_generator.for(style_name, .merge(:timestamp => )) else @url_generator.for(style_name, .merge()) end end |