Rails: Fast & Easy Sitemaps

Few lines to get your sitemap. Also, add a hash array for the other links on your site:

Sitemap controller:

    @sites = [
	    {:loc=>url_for(:controller=>'home',:action=>nil), :lastmod=>File.open('web/app/views/home/index.rhtml').mtime.strftime('%Y-%m-%d')},
	    {:loc=>url_for(:controller=>'blog',:action=>nil), :lastmod=>File.open('web/app/views/blog/index.rhtml').mtime.strftime('%Y-%m-%d')},
	    {:loc=>url_for(:controller=>'casa',:action=>nil), :lastmod=>File.open('web/app/views/casa/index.rhtml').mtime.strftime('%Y-%m-%d')}
    ]

 

RXML:

  @sites.each do |site|
    xml.url do
      xml.loc( site[:loc] )
      xml.lastmod( site[:lastmod] )      
    end	    
  end