In building a sitemap for my rails app, I went off of this blog post:
http://tonycode.com/wiki/index.php?title=Ruby_on_Rails_Sitemap_Generator
but I have public-facing pages for which no ActiveRecord model exists.
I added the following to my sitemap controller to add entries for a given
controller:
Then, for example, in my controller I just call:
@info_pages = get_public_action_urls(InformationPagesController)
and finally, in my view:
@info_pages.each do |entry|
xml.url do
xml.loc entry
xml.lastmod w3c_date(Time.now)
xml.changefreq "weekly"
xml.priority 0.9
end
end
xml.url do
xml.loc entry
xml.lastmod w3c_date(Time.now)
xml.changefreq "weekly"
xml.priority 0.9
end
end
oh, and in my sitemap_helper:
def w3c_date(date)
date.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
end
date.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
end