2

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?

6
  • not too much info to go on... i assume you have a controller action named sitemap inside xmls_controller.rb? Do you have a folder named xmls in your views with the file, 'sitemap.html.erb'? Commented Aug 3, 2015 at 0:26
  • is it okay if you put your sitemap.xml to your public folder instead? Commented Aug 3, 2015 at 3:27
  • @nayiaw How would I define a url for something in my public folder? Commented Aug 3, 2015 at 10:08
  • @RickyMason I have no such controller action. All I have is a file called 'sitemap.xml' in my xml folder. Commented Aug 3, 2015 at 10:08
  • 1
    if you want to load static sitemap.xml you can put the sitemap.xml in your public folder then load the sitemap directly <domain.com>/sitemap.xml without any routing. However use a sitemap generator like sitemap_generator is recommended as content changes over time. Commented Aug 3, 2015 at 11:38

1 Answer 1

1

If you want to load static sitemap.xml you can put the sitemap.xml in your public folder, then load the sitemap directly <domain.com>/sitemap.xml without any routing. However use a sitemap generator like sitemap_generator is recommended as content changes over time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.