Template html/xhtml confusion in Rails 2

Doing my first Rails 2 project I’m utterly confused by Rails’ behavior
concerning the use of html or xhtml in templates and the MIME types
the final documents get send as.
I have one controller that uses a layout. Within the layout tag helper
methods return xhtml self-closing tag. But in the template for the
individual actions html tags are used. The final document is
transmitted as application/xml.
Another controller — without a layout — transmits its actions as text/
html but uses xhtml tags.
I have not tempered with any configs regarding this. I only
experimented with the new template extensions, but found that
using .xhtml.erb was not the way to toggle between the use of html or
xhtml.
Can anybody please shed some light on this, please?
Thank you!

sebastian wrote:

Doing my first Rails 2 project I’m utterly confused by Rails’ behavior
concerning the use of html or xhtml in templates and the MIME types
the final documents get send as.
I have one controller that uses a layout. Within the layout tag helper
methods return xhtml self-closing tag. But in the template for the
individual actions html tags are used. The final document is
transmitted as application/xml.
Another controller � without a layout � transmits its actions as text/
html but uses xhtml tags.
I have not tempered with any configs regarding this. I only
experimented with the new template extensions, but found that
using .xhtml.erb was not the way to toggle between the use of html or
xhtml.
Can anybody please shed some light on this, please?
Thank you!

Im not sure whats going on in your headers, but I am confused that you
say you are getting mixed html and xhtml tags in your code. All the
rails tag helpers should generate xhtml just fine. Other than that,
rails won’t process your HTML at all. So if you insert unclosed single
tags in your erb templates, thats exactly how they will be sent out.

Thanks for the reply, Alex
You are, of course, right: the stray html tags where after all my own
doing.
And that one controller returned application/xml stemmed from the
circumstance that in its layout I use a Builder template.
Sometimes it’s just better to call it a day early and sleep it over —
in this case at 4 pm. :slight_smile:
Cheers,
Sebastian

On May 13, 10:15Â pm, Alex W. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs