Paul Canavese
2008-Jul-09 21:13 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---