---
title: what, is it good for? absolutely nothing
teaser:
tags: news,web,rails
author: Jared Carroll
published_on: 2008-02-22
---

Ever write this?

    before_filter :csv?, :only => :index

    def index
      respond_to do |format|
        format.html { @users = User.all }
        format.csv { @users = User.to_csv }
      end
    end

    def csv?
      if request.format == :csv && ! logged_in?
        log_in
      end
    end

This would be a lot nicer if we could get rid of that #== in #csv?

    def csv?
      if request.format.csv? && ! logged_in?
        log_in
      end
    end

![Lil Jon drinks the CRUD juice.](http://data.tumblr.com/1TEAMALps5lj8pdq0mFpWKKz_400.png)

## Introducing What

[What](https://svn.thoughtbot.com/plugins/what/) is a plugin that automatically
adds those nice query methods to ActionController::Mime::Type, the type of
object returned by Request#format. All the built in mime types are supported.
Any custom mime types that you add will also have corresponding query methods.
