There are a lot of sitemap tutorials for rails out there. My current project required a different approach for this as we didn't want our app controller clogged by requests from a spider gone awry. So my boss suggested this cool way of generating the sitemap outside of a regular sitemap controller. We created a sidekiq job using that creates the sitemap and uploads it to a CDN.
The Sitemap controller works this way because spiders reject sitemap stored offsite. The Sidekiq job can be run on a weekly or daily basis using the 'whenever' gem. I used the 'carrierwave' gem for uploading the sitemap to S3.