Paperclip::Attachment.interpolations [ DEPRECATION ]

168 views
Skip to first unread message

erwin

unread,
Jul 21, 2009, 10:02:12 AM7/21/09
to Paperclip Plugin
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
[DEPRECATION] Paperclip::Attachment.interpolations is deprecated and
will be removed from future versions. Use Paperclip.interpolates
instead

does someone knows how should we write the block now ?

Paperclip::Attachment.interpolations[:content_type_extension] = proc
do |attachment, style_name|
....
end

thanks a lot fyh

erwin

lardawge

unread,
Jul 21, 2009, 5:04:18 PM7/21/09
to Paperclip Plugin
Paperclip.interpolations :content_type_extension do |attachment,
style_name|
....
end

On Jul 21, 10:02 am, erwin <kadou...@gmail.com> wrote:
> => Rails 2.3.2 application starting onhttp://0.0.0.0:3000

erwin

unread,
Jul 22, 2009, 2:29:06 AM7/22/09
to Paperclip Plugin
thanks.. looking into the plugin, it seems that :

Paperclip.interpolates :content_type_extension do |attachment,
style_name|

would be better, it's not it ?

Jonathan Yurek

unread,
Jul 28, 2009, 4:03:27 PM7/28/09
to papercli...@googlegroups.com
Yes, this is what you should be doing:

Paperclip.interpolates :interpolation do |attachment, style|
"some string replacement"
end
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

lardawge

unread,
Jul 29, 2009, 10:29:49 AM7/29/09
to Paperclip Plugin

Oops. Read it right, typed it wrong... I was almost there:)

JL Smith

unread,
Aug 7, 2009, 11:10:05 PM8/7/09
to Paperclip Plugin
I'm new to Paperclip but where exactly do we put these
interpolations? Thanks.

erwin

unread,
Aug 10, 2009, 2:27:58 AM8/10/09
to Paperclip Plugin
It's an initialization process
you can create a paperclip.rb in config/initializers/

mine has 2 interpolations

# a more complex one (I have different types of assets)
Paperclip.interpolates :content_type_extension do |attachment,
style_name|
case
when ((style = attachment.styles[style_name]) && !style
[:format].blank?) then style[:format]
when attachment.instance.video? && style_name.to_s == 'transcoded'
then 'flv'
when attachment.instance.audio? && style_name.to_s == 'thumb' then
'jpg'
when attachment.instance.video? && style_name.to_s != 'original'
then 'jpg'
else
File.extname(attachment.original_filename).gsub(/^\.+/, "")
end
end


#or a more simpler for user avatar attachment
Paperclip.interpolates :username do |attachment, style_name|
attachment.instance.username
end

JL Smith

unread,
Aug 10, 2009, 9:59:38 AM8/10/09
to Paperclip Plugin
Thanks erwin.
Reply all
Reply to author
Forward
0 new messages