What does respond_to do when called without a block?

Viewed 1721

I understand how respond_to works when it's called with something like this:

def index
  @users = User.all
  respond_to do |format|
    format.html
    format.json { render json: @users }
  end
end

But I've seen some apps which pass respond_to a list of symbols, outside of the controller methods, e.g.:

class UsersController < ApplicationController

  respond_to :html, :json

  def index
    # blah blah bah
  end
end

What does this do? I've been playing around with it in one of my controllers and I can't figure out what difference it makes.

1 Answers
Related