title: Jqgrid and belongs_to relationship
body: <p>Is it possible to display a <code>belongs_to</code> relationship in a single jqgrid?</p>
  
  <p>Example:</p>
  
  <p><code>Vehicle</code> belongs to <code>Person</code></p>
  
  <p>I can display the <code>Vehicle</code> jqgrid listing the person_id, but I would like to display the <code>Person</code>'s name instead of their id.</p>
  
  <p>Example:</p>
  
  <pre><code>person_id|vehicle_type
      1    |    honda 
  
  
  person_name|vehicle_type
      Tom    |    honda
  </code></pre>
  
  <p><strong>EDIT (Vehicle controller code):</strong></p>
  
  <pre><code>class VehiclesController &lt; ApplicationController
  
    def index
      @vehicles = Vehicle.find(:all) {
        if params[:page].present? then
          paginate :page =&gt; params[:page], :per_page =&gt; params[:rows]
          order_by "#{params[:sidx]} #{params[:sord]}"
        end
      }
  
      respond_to do |format|
        format.html # index.html.erb
        format.xml  { render :xml =&gt; @vehicles }
        format.json  { render :json =&gt; @vehicles }
        format.jgrid {
          render :json =&gt; @vehicles.to_jqgrid_json(
            [:person_id, :vehicle_type],
            params[:page],
            params[:rows],
            @vehicles.total_entries
          )
        }
      end
    end
  end
  </code></pre>