Multiview: Format fallback from fbml to html (register_alias/request.format)

I’m using Rails 2.1 with the Multiview template mechanism to create a
hybrid Facebook and public site. For the most part, there are
analogous views across the two. Since Facebook supports a subset of
HTML, some of my HTML views and partials could be shared across the
two.

I have registered a Mime type alias for FBML in my mime_types.rb:
Mime::Type.register_alias(“text/html”, :fbml)
and have a filter in my controller to set it appropriately:
request.format = :fbml
That all seems fine.

I would like to use an FBML template (e.g. “foo.fbml.erb”) if it
exists, but otherwise fall back to an HTML template (e.g.
“foo.html.erb”). I have seen references that it should work like this
already (e.g.
http://locomotivation.com/2008/06/28/redesign-your-site-in-place-using-rails-custom-mime-types),
but I get “Template is missing” errors if the FBML template is not
there.

It seems to work to name common templates without a format (e.g.
“foo.erb”), which I am doing now, but is there a way to get it to
default back to HTML first?

Regards,

Paul

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