我的 Rails 应用程序中有一个 Controller Projects:
caches_page :index
但是,缓存文件不是在 /public/projects/index.html
生成,而是位于 /public/projects.html
。
Web 服务器(目前是 Mongrel)在 *.html
文件之前查找 */
目录。因此,http://…/projects
请求通过 Rails 进行路由,而我的索引缓存文件从未得到服务。
我如何告诉 caches_page :index
在 /public/projects/index.html
生成文件?
最佳答案
您可以通过将以下内容添加到您的 environment.rb 配置 block 来指定目录
config.cache_store = :file_store, "#{RAILS_ROOT}/public/projects"
其他一些事情:
缓存设置已经改变了一些 使用不同版本的 Rails, 知道什么会很有帮助 您正在运行的版本
一般来说,您最好使用缓存内存存储而不是文件存储(如果您的机器中有足够的 RAM)。
关于ruby-on-rails - Rails caches_page :index in Wrong Location,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2622242/