【发布时间】:2013-10-29 10:58:50
【问题描述】:
我正在为我的网站生成站点地图并将其临时保存到 tmp 文件夹,然后上传到我的亚马逊 AWS 账户。我正在使用站点地图生成器和雾宝石来帮助我。到目前为止,我有这个......
# In sitemap.rb
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "http://mycoolapp.com/"
# pick a place safe to write the files
#SitemapGenerator::Sitemap.public_path = 'tmp/'
# store on S3 using Fog
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new
# inform the map cross-linking where to find the other maps
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/"
# pick a namespace within your bucket to organize your maps
SitemapGenerator::Sitemap.sitemaps_path = '/'
SitemapGenerator::Sitemap.create do
# Put links creation logic here.
#
add '/home'
add '/about'
add '/contact'
end
每当我运行heroku run rake sitemap:create 时,我都会收到以下错误...
In '/app/tmp/':
511
rake aborted!
Read-only file system - /sitemap.xml.gz
我真的不知道为什么它不起作用。我什至通过运行Rails.root.join('tmp') 作为初始化程序来确保创建 tmp 文件夹。任何解决此问题的帮助将不胜感激。
【问题讨论】:
-
不幸的是,heroku 不允许您直接修改文件系统 - 您必须在内存中构建站点地图并将它们流式传输到 aws 而不使用临时文件。
-
嗯,有什么链接可以帮助我继续前进吗?
-
我以前读过这篇文章,但对我没有多大帮助。如果它告诉我我的代码应该可以工作,因为我正在将它写入 tmp,
There are two directories that are writeable: ./tmp and ./log。我对什么感到困惑?
标签: ruby-on-rails heroku rake sitemap