Quantcast
Viewing all articles
Browse latest Browse all 8

A catch-all format (ActionController::MimeResponds::InstanceMethods#respond_to)

If you’d like to specify a respond_to only for 1 or a few formats and render something else for all other formats, eg: (action.rss returns a feed but action.html or action.js should just render 404), use format.all:

respond_todo|format|format.rss{render_rss}format.all{render_404}end

Rails will render an empty string for all formats that don’t specify a response explicitly.


Viewing all articles
Browse latest Browse all 8

Trending Articles