How to tell which format a controller has resolved to render

Solution 1:

The method to access the format is:

controller.request.format

Solution 2:

in your controller you can do:

request.format
request.format.html?
request.format.js?
request.format.json?
# etc.