This project is archived and is in readonly mode.

#1143 ✓hold
Zach Dennis

Make #respond_to implicit in controller actions

Reported by Zach Dennis | September 30th, 2008 @ 04:04 PM | in 3.0.2

Currently when using different formats in a controller you have to be explicit with the respond_to.

ie:


def some_action
  respond_to do |format|
    format.html { do this }
    format.xml  { do this }
    format.json { do this }
  end
end

It seems that you should be able to just use format and have that automatically handle the responder. For example:


def some_action
    format.html { do this }
    format.xml  { do this }
    format.json { do this }
end

Attached is a simple patch by Brandon Keepers and myself to make this so. One limitation is that this won't work in before filters. We realize this may be desired, but feel it can be a separate patch and shouldn't affect the inclusion of this functionality for a controller action.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages