ruby-on-rails - Carrierwave(开发环境)图像中的本地存储设置渲染效果不佳

标签 ruby-on-rails carrierwave

为什么我会看到这样的图像...

http://i46.tinypic.com/16bn0js.png

图像存储在我的 tmp/uploads 文件夹中:

顺便说一句,我将此条件放入了 ads_uploader.rb

       if Rails.env.production?
    CarrierWave.configure do |config|
      config.storage :fog
      def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
      end

      def cache_dir
      "#{Rails.root}/tmp/uploads"
      end
    end
  end


  if Rails.env.development?

    CarrierWave.configure do |config|
      config.root = Rails.root
      config.storage :file

      def
      store_dir
        "#{Rails.root}/tmp/uploads"

      end

      #I am not sure about this one ~SS
      def cache_dir
        "#{Rails.root}/tmp/uploads"
      end
    end


  end

开发环境中上传过程成功。该文件存储在 tmp/uploads 目录中。

但是在 View 中查看它时。

ads.html.haml:

图像未显示。 (参见上面的图片网址)

请帮忙。我错过了诸如网址之类的东西吗?

最佳答案

尝试

def store_dir
  "#{Rails.root}/public/uploads"
end

“/tmp”无权直接提供资源,请移至公开查看

关于ruby-on-rails - Carrierwave(开发环境)图像中的本地存储设置渲染效果不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12103257/

相关文章:

html - link_to_unless_current 将类分配给禁用的(当前)链接

ruby-on-rails-3 - Carrierwave 直接上传到 s3,sidekiq 验证失败

serialization - serializable_hash 中的载波双键

ruby-on-rails - 如何在索引 View 中显示图像

ruby-on-rails - User 模型中的父子关系(自联接)

mysql - rails COUNT SELECT DISTINCT

ruby-on-rails - 在 Gemfile 中列出的任何 gem 源中都找不到 gem 'mysql2 (< 0.5, >= 0.3.18)'

jquery - 如何使用 Rails 和 jQuery 实现图像预览?

ruby-on-rails-3 - 将参数传递给 uploader /从 uploader 中访问模型的属性/让用户选择缩略图大小

ruby-on-rails - 如何使用carrierwave从图像中删除EXIF(相机)数据?