ruby on rails - carrierwave - create thumb for pictures and videos in same uploader -


i trying create thumb pictures or videos in same uploader ad model...

so far, trying create conditional thumb that:

  version :thumb       process :resize_to_limit => [50, 50]   if %w(jpg jpeg gif png).include?(file.extension)           process :screenshot => 5 if %w(mpg avi).include?(file.extension)     end   end 

but apparently, errors on file.extension part this

nameerror: undefined local variable or method `file' 

does know how file extension in uploader?

your code looks carrierwave generated uploader class , if understand question correctly, looking way restrict type of file can turned thumbnail. can whitelist types of files uploader class accept - in uploader class :thumb method located include following :

    # add white list of extensions allowed uploaded.     # images might use this:     def extension_white_list       %w(jpg jpeg gif png)     end 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -