创建生产链接的站点地图?

时间:2016-04-01 21:05:11

标签: ruby-on-rails ruby amazon-web-services amazon-s3 aws-sdk

站点地图存储我在开发中制作的链接。如何从生产中获取链接?

$ rake sitemap:create

In '/Users/galli01anthony/Dropbox/LiveToChallenge/public/sitemaps/':
+ sitemap.xml.gz                                         133 links /    2.09 KB
Sitemap stats: 133 links / 1 sitemaps / 0m02s

Pinging with URL 'http://www.livetochallenge.com/sitemap.xml.gz':
  Successful ping of Google
  Successful ping of Bing

default_host是正确的,但它显示的是http://www.livetochallenge.com/challenges/19-test之类的链接,这些链接在生产中不存在。 http://0.0.0.0:3000/challenges/19-test仅存在于开发中。

sitemap.rb

SitemapGenerator::Sitemap.default_host = 'http://www.livetochallenge.com/'
SitemapGenerator::Sitemap.public_path = 'public/sitemaps/'

SitemapGenerator::Sitemap.create do
  add posts_path, changefreq: 'daily'
  add challenges_path, changefreq: 'daily'
  add inspirations_path, changefreq: 'weekly'
  add users_path, changefreq: 'weekly'
  add activities_path, changefreq: 'weekly'
  add about_path, changefreq: 'monthly'
  Post.find_each do |f|
    add post_path(f.slug), lastmod: f.updated_at
  end
  Challenge.find_each do |f|
    add challenge_path(f), lastmod: f.updated_at
  end
  Inspiration.find_each do |f|
    add inspiration_path(f), lastmod: f.updated_at
  end
  User.find_each do |f|
    add user_path(f), lastmod: f.updated_at
  end
end

SitemapGenerator::Sitemap.ping_search_engines

1 个答案:

答案 0 :(得分:1)

您似乎正在开发环境中运行rake任务,因此它会从您的开发数据库中提取记录。确保您已将ENV设置为生产环境:RAILS_ENV=production bundle exec rake sitemap:create并且您已能够连接到生产数据库。

相关问题