title: How do I use respond_with with custom classes in Rails 3?
body: <p>I am making a JSON API with Rails and it seemed to work fine except for when I use <code>respond_with</code> custom classes (not an ActiveRecord inherited one).</p>
  
  <p>Here is my class:</p>
  
  <pre><code>class JsonResponse
    def initialize(data, status)
      @data = data
      @status = status
    end
  
    def as_json(options={})
      {
        :data =&gt; @data,
        :status =&gt; @status
      }
    end
  end
  </code></pre>
  
  <p>which is a simple response wrapper. When I try doing this:</p>
  
  <pre><code>def create
    unless(Match.find_by_user_id(params[:user_id]))
      Match.create(:user_id =&gt; params[:user_id])
    end
    time_response = JsonResponse.new("5", "success")
    respond_with(time_response)
  end
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>NoMethodError (undefined method `model_name' for JsonResponse:Class):
    app/controllers/matches_controller.rb:9:in `create'
  </code></pre>
  
  <p>Any ideas? <code>respond_with</code> is driving me crazy.</p>