Override Controller Response

I have a website completed and am now looking into providing services
for the data the site uses. What would be nice is if I could somehow
override the template parsing and output and instead render and return
an XML request (as defined by a different set of templates that I will
create). I don’t want to just cut and paste all of the logic and error
handling that gets pulled when retrieving the data from the database.
What I want to do is run the code in the controller actions but then
just intercept any rhtml rendering and instead render XML templates? Is
there a graceful way to do this without duplicating controller code?

On 10/12/06, Caleb [email protected] wrote:

You probably want to look at respond_to.

respond_to do |wants|
wants.html do
… render html …
wants.xml do
… render xml …

There are a few tutorials/examples around as well.


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