开发者

Getting "NoMethodError (undefined method `extension'..." when trying to run in production on heroku

HI my app works fine locally when using :file but once i'ts pushed up to heroku and using S3 I get this error when trying to upload. It looks to be a porblem with the def filename method.

The heroku logs show:

 NoMethodError (undefined method `extension'开发者_StackOverflow for #<CarrierWave::Storage::S3::File:0x00000006316a90>):
 app/uploaders/image_uploader.rb:53:in `filename'

This is how I have filename defined in my uploader:

  def filename
       "image.#{model.image.file.extension}" if original_filename
     end

How can i fix this? Thanks!


Try this:

def filename
  "image.#{File.extname(original_filename).downcase}" if original_filename
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜