0

在开发/测试模式下,我在 config/environments/*.rb 中添加以下内容:

config.assets.paths << "whatever_path"

当我启动 webrick 时,可以通过以下路径访问“whatever_path/collections/image.jpg”中的图像:

http://0.0.0.0:3000/assets/collections/image.jpg

如何(没有 fs 操作)可以通过此路径访问它:

http://0.0.0.0:3000/collections/image.jpg 

我需要此重定向仅在测试模式下工作。

4

1 回答 1

0

作为我的问题的替代解决方案,我在 features/support/asset_host.rb 中添加了以下内容

ActionController::Base.asset_host = Proc.new { |source|
  true if source["/collections"] and File.exists?(Rails.root.join("whatever_path",source[1..-1]))
}

仅当文件存在于任何路径的虚拟 fs 中时,这才会抑制错误

于 2013-10-17T11:09:24.167 回答