Brian Walsh
2006-Oct-31 16:54 UTC
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2006-Oct-31 17:21 UTC
Re: newbie question: specifying view dynamically (html vs. x
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---