Ruby on rails 更改Rails 4中的临时目录
我希望更改Rails4中的临时目录。默认值是Ruby on rails 更改Rails 4中的临时目录,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,我希望更改Rails4中的临时目录。默认值是“35;{Rails.root}/tmp”,但我想将其更改为其他值,例如:“/tmp” 我发现了如何从“#{Rails.root}/tmp”更改缓存目录: 链轮似乎仍在使用默认的tmp目录进行缓存 在Rails 3项目中,我在我的config/application.rb中添加了以下内容: if ENV['RAILS_TMP'].present? config.cache_store = :file_store, ENV['RAILS_TMP']
“35;{Rails.root}/tmp”
,但我想将其更改为其他值,例如:“/tmp”
我发现了如何从“#{Rails.root}/tmp”
更改缓存目录:
链轮似乎仍在使用默认的tmp目录进行缓存
在Rails 3项目中,我在我的config/application.rb
中添加了以下内容:
if ENV['RAILS_TMP'].present?
config.cache_store = :file_store, ENV['RAILS_TMP'] + '/cache/'
config.assets.cache_store = :file_store, ENV['RAILS_TMP'] + '/assets'
config.sass.cache = false
end
设置RAILS\u TMP会导致TMP dir发生更改。我有一种奇怪的感觉,这是现在硬编码的。创建一个新的初始化文件,比如over_ride\u temp\u path.rb,并在其中粘贴以下代码
class Dir
def self.tmpdir
<path of the directory to be used as temp>
end
end
class目录
def self.tmpdir
结束
结束
我不确定这是否能正常工作,但在/config/application.rb
中,请尝试:
config.paths.add("tmp", with: ENV['RAILS_TMP'])
似乎有些库喜欢硬编码值。。。见: 通过添加以下内容,可以绕过硬编码值:
config.assets.cache_limit = 50.megabytes
config.assets.configure do |env|
env.cache = Sprockets::Cache::FileStore.new(
File.join(ENV['RAILS_TMP'], 'cache/assets'),
config.assets.cache_limit,
env.logger
)
end
这会更改Ruby临时目录,但不会更改Rails使用的临时目录,正如在question.doh!有人应该给Sprocket rails发送一个补丁来修复这个问题。看起来这里有另一个硬编码的tmp,这会有问题吗@这不是一个问题,因为引用的代码在sprockets-rails测试中,这对库用户没有影响。
config.assets.cache_limit = 50.megabytes
config.assets.configure do |env|
env.cache = Sprockets::Cache::FileStore.new(
File.join(ENV['RAILS_TMP'], 'cache/assets'),
config.assets.cache_limit,
env.logger
)
end