This is how I generate my google sitemap for my sites: :).
1. First, create a controller named xml.
2. Then, for example for the tag links create this method in xml_controller.rb
# in xml_controller.rb
def tags
@tags = Tag.find(:all, :conditions=> "approved = true")
end
def tags
@tags = Tag.find(:all, :conditions=> "approved = true")
end
3. In the Views/xml create a tag.rxml file:
# in views/xml/tags.rxhml
xml.instruct! :xml, :version=>"1.0"
xml.urlset(:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"){
@tags.each do |tag|
xml.url{
xml.loc(tag_url(:tag=>tag))
xml.priority(0.9)
xml.changefreq("weekly")
}
end
}
xml.instruct! :xml, :version=>"1.0"
xml.urlset(:xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9"){
@tags.each do |tag|
xml.url{
xml.loc(tag_url(:tag=>tag))
xml.priority(0.9)
xml.changefreq("weekly")
}
end
}
4. In routes.rb add the route:
#routes.rb
map.tag ‘tag/:tag’, :controller=>"tag", :action=>"view"
map.connect ‘tags.xml’, :controller => "xml", :action => "tags"
map.tag ‘tag/:tag’, :controller=>"tag", :action=>"view"
map.connect ‘tags.xml’, :controller => "xml", :action => "tags"
5. Type localhost:300x/tags.xml
This is the magical code that I use :). I just create a separate method for each model (products, categories, etc).

January 12th, 2008 at 7:10 pm
Now that is probably the shortest sitemap generator I have ever seen, congratulations!
I just wanted to comment on the “priority” and “changefreq”: in general, if you are unsure of these values, just leave them out. Those values are optional so there’s no need to specify static ones for each URL (and it shortens your generator even more :-)). Could you get the change date of the URLs?