Fernando Perez wrote:
> Okay so it has to do with caching. On my dev machine, if I switch to 
> production environment I get the same behavior. I don't know what's the 
> solution.

You're encountering this because Paperclip was originally built to 
process a file into different sizes of itself, original, medium, 
thumbnail etc. In that scenario the format stays the same, so if you use 
a jpg you'll have a thumbnail jpg as well.

When you're looking at converting to a different format or, in your 
case, capturing a still it doesn't check the mime-type for every style 
it has. There is at least one branch on github where somebody has 
attempted to solve this, but here is the approach I've followed:

1. Create an initializer at

# config/initializers/paperclip.rb

Paperclip.interpolates :style_extension do |attachment, style|
  default = File.extname(attachment.original_filename).gsub(/^\.+/, "")

  case style.to_s
  when /theora/ then 'ogv'
  when /still/      then 'jpg'
  else
    default
  end
end

2. Use that interpolation in your url and path options:
  :url    => "/uploads/products/:basename:suffix.:style_extension",
  :path => 
":rails_root/uploads/products/:basename:suffix.:style_extension"


For reference on interpolations: 
http://rdoc.info/projects/thoughtbot/paperclip

Hope it helps!

- Parker
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to