I'm trying to upload an .xml sitemap to my Rails app called sitemap.xml. When I define a route as such:
get "sitemap", to: 'xml#sitemap'
I get the following error:
Template is missing
Missing template xml/sitemap, application/sitemap with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * "/home/user/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/web-console-2.0.0/lib/action_dispatch/templates" * "/home/user/website/app/views"
How can I define a proper Rails route for an .xml file?
xmls_controller.rb? Do you have a folder namedxmlsin your views with the file, 'sitemap.html.erb'?sitemap.xmlto yourpublicfolder instead?sitemap.xmlyou can put thesitemap.xmlin your public folder then load the sitemap directly<domain.com>/sitemap.xmlwithout any routing. However use a sitemap generator like sitemap_generator is recommended as content changes over time.