Newbie question: specifying view dynamically (html vs. xml)

Hello all,

I’m brand new ruby user.

Does RoR support following use case?

I’d like to maintain a single set of controllers. However, based on
either configuration or request parameter, I’d like to route the to
either a .rhtml or an .rxml view. In other words, I’d like the same set
of controllers to support a traditional browser app or a REST style xml
service.

It seems that in Ruby, the controller specifies a single view (via
layout, scaffold, etc.).

Is it possible to make the controller–>view specification dynamic?

Thanks.

First of all, you can always call render … and tell it which view you
want to render.

In your case, it sounds like you want respond_to
so, you can do things like

respond_to do |wants|
wants.html { #do html render}
wants.xml { #do xml render }
end

Fred