No, this is not a real Sinatra error :).
This is the personal homepage of Elad Meidar, a web developer and an entrepreneur specializing in Ruby on Rails. I hang around in Israel, and i am currently having the best time of my life over at Fiverr.com
I am a proud member of RailsBridge, Helping new Rails developers get into our world and also contributed a few Patches to the Ruby on Rails core.
:path definition in paperclip is basically an interpolated string, with a few tokens:
:rails_root– The path to the Rails application.
:rails_env– The current environment (e.g. development, production)
:class– The class name of the model that the attachment is part of, underscored and pluralised for your convenience.
:basename– The name of the originally uploaded file without its extension.
:extension– The file extension of the originally uploaded file.
:id– The ID of the model that the attachment is part of.
:id_partition– The same as :id but formatted as a string using ID partitioning.
:attachment– The name of the attachment attribute (defined in the call to has_attached_file) downcased and pluralised for your enjoyment.
:style– The current style of the attachment file being processed (e.g. in the ‘discarding an uploaded image‘ example above the
:stylewould be one of ‘original’ or ‘small’)
But what if you want some other token? like and association id for example?
Let’s say we have a
Album, and we want the
album_id in out path.
First, we’ll add a custom token to our Paperclip installation. Create a file in
Paperclip::Attachment.interpolations[:photos_album_id] = proc do |attachment, style|
attachment is out uploaded file,
instance is the model instance which the uploaded file belongs to (Photo instance) and
album_id is the attribute.
Than we can use it in our paperclip setup in the
:url => ‘/:attachment/:photos_album_id/:style/:basename.:extension’,
:path => ‘:rails_root/public/:attachment/:photos_album_id/:style/:basename.:extension’
You're seeing this error because I think it is funny.