I have added the following to my application controller so that rails
sets the content_type header to application/xhtml+xml if the browser
accepts that mime-type and defaults to text/html otherwise.
request.format = :xhtml if browser_accepts_xhtml?
I haven’t added any “respond_to |format|” blocks for my actions (and I
don’t want to) but instead I name my view template home.erb rather
than home.xhtml.erb and rely on the fact that if a format-specific
template cannot be found then rails will resort to using that default
template. This way I can use a single template for both the html and
xhtml formats without having to write a lick of code.
However, if the format is :html then my layout template, layouts/
application.erb will be included as expected but if the format
is :xhtml then the layout is not included for some reason. Does anyone
know why not and what I can do to get it included for the :xhtml
format without having to write respond_to blocks in all of my actions?