Skip to content

Instantly share code, notes, and snippets.

@jaimeiniesta
Created August 9, 2010 10:56
Show Gist options
  • Select an option

  • Save jaimeiniesta/515275 to your computer and use it in GitHub Desktop.

Select an option

Save jaimeiniesta/515275 to your computer and use it in GitHub Desktop.
class SitemapController < ApplicationController
def sitemap
@plants = Plant.find(:all)
respond_to do |format|
format.xml
end
end
end
###############
# sitemap.rxml
###############
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
@plants.each do |entry|
xml.url do
xml.loc "http://www.floracatalana.net/#{entry.slug}"
xml.lastmod entry.updated_at.to_date
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment