How do I specify “:layout => false” in Rails' respond_with?

后端 未结 7 1860
星月不相逢
星月不相逢 2020-12-13 18:37

I have this setup:

class UsersController < InheritedResources::Base
  respond_to :html, :js, :xml, :json

  def index
    @users = User.all
    respond_wi         


        
相关标签:
7条回答
  • 2020-12-13 19:12

    Or to prevent you having to hardcode responses for each format in each action.

    If you have no layouts for any of the actions in this controller it would be nicer to do:

    class UsersController < InheritedResources::Base
      respond_to :html, :js, :xml, :json
      layout false
    
      def index
        @users = User.all
        respond_with(@users)
      end
    end
    
    0 讨论(0)
提交回复
热议问题