Rails 3 respond_to: default format?

前端 未结 5 594
[愿得一人]
[愿得一人] 2020-12-08 01:56

I am converting a Rails 2 application to Rails 3. I currently have a controller set up like the following:

class Api::RegionsController < ApplicationContr         


        
5条回答
  •  半阙折子戏
    2020-12-08 02:27

    An easy but ugly solution is to override html content type handling to render xml:

       respond_to :html, :xml, :json
    
       def index
          @regions = Region.all
          respond_with @regions do |format|
            format.html { render :xml => @regions }
          end
        end
    

提交回复
热议问题