从tmp目录读取时出现路由错误

时间:2014-11-17 14:12:29

标签: ruby-on-rails ruby heroku carrierwave

我使用carrierWave上传tmp目录中的封面,但是当尝试访问它们时遇到路由错误,尝试使用Rack :: static来侦听请求但是没有解决它,

*注意我无法执行操作并使用send_file,因为它没有在heroku上工作!

#config.ru
require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Static, :urls => ["/uploads"], :root => "tmp"
run Aa::Application

#CarrierWave.rb
CarrierWave.configure do |config|
 config.root = Rails.root.join('tmp') # adding these...
 config.cache_dir = 'uploads' # ...two lines
end

#cover_uploader.rb
class CoverUploader < CarrierWave::Uploader::Base

  include CarrierWave::RMagick

  storage :file

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

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

end

0 个答案:

没有答案