title: Joining information from two CouchDB models in Rails view
body: <p>I'm using Couchrest_model as a Rails ORM to CouchDB. I want to have Rails do a "join" of information from two different CouchDB documents for a view, but can't seem to get Rails to auto-retrieve the joined data.</p>
  
  <p>Here's the two related models:</p>
  
  <pre><code>class Package &lt; CouchRest::Model::Base                                                                                                                                                                                                                                                                                                
    belongs_to :vendor                                                                                                                                                            
  
    property :shortcode, String                                                                                                                                                   
    property :pins, Integer                                                                                                                                                       
  
  end
  
  class Vendor &lt; CouchRest::Model::Base                                                                                                                                           
    property :vendor, String                                                                                                                                                      
    timestamps!                                                                                                                                                                   
  end                                                                                                                                                                             
  </code></pre>
  
  <p>So, now in my index.html.erb for /packages I want to display a table with the data from my two models:</p>
  
  <pre><code>&lt;h1&gt;Listing packages&lt;/h1&gt;                                                                                                                                                       
  
  &lt;table&gt;                                                                                                                                                                         
    &lt;tr&gt;                                                                                                                                                                          
      &lt;th&gt;Shortcode&lt;/th&gt;                                                                                                                                                          
      &lt;th&gt;Pins&lt;/th&gt;                                                                                                                                                                                                                                                                                                                   
      &lt;th&gt;Vendor&lt;/th&gt;                                                                                                                                                             
      &lt;th&gt;&lt;/th&gt;                                                                                                                                                                   
    &lt;/tr&gt;                                                                                                                                                                         
  
  &lt;% @packages.each do |package| %&gt;                                                                                                                                               
    &lt;tr&gt;                                                                                                                                                                          
      &lt;td&gt;&lt;%= package.shortcode %&gt;&lt;/td&gt;                                                                                                                                           
      &lt;td&gt;&lt;%= package.pins %&gt;&lt;/td&gt;                                                                                                                                                                                                                                                                                     
      &lt;td&gt;&lt;%= package.vendor %&gt;&lt;/td&gt;                                                                                                                                         
      &lt;td&gt;&lt;%= link_to 'Show', package %&gt;&lt;/td&gt;                                                                                                                                     
      &lt;td&gt;&lt;%= link_to 'Edit', edit_package_path(package) %&gt;&lt;/td&gt;                                                                                                                  
      &lt;td&gt;&lt;%= link_to 'Destroy', package, confirm: 'Are you sure?', method: :delete %&gt;&lt;/td&gt;                                                                                       
    &lt;/tr&gt;                                                                                                                                                                         
  &lt;% end %&gt;                                                                                                                                                                       
  &lt;/table&gt;                                                                                                                                                                        
  
  &lt;br /&gt;                                                                                                                                                                          
  
  &lt;%= link_to 'New Package', new_package_path %&gt;  
  </code></pre>
  
  <p>I want to display the vendor string from the Vendor model. I've used a selector helper in a view to display "joined" information across models with CouchDB, but I can't figure out how to join in this seemingly simpler case of just printing the string in the view table.</p>
  
  <p>Here's the Package controller that corresponds to the index, which is pretty standard:</p>
  
  <pre><code>class PackagesController &lt; ApplicationController                                                                                                                                
    # GET /packages                                                                                                                                                               
    # GET /packages.json                                                                                                                                                          
    def index                                                                                                                                                                     
      @packages = Package.all                                                                                                                                                     
  
      respond_to do |format|                                                                                                                                                      
        format.html # index.html.erb                                                                                                                                              
        format.json { render json: @packages }                                                                                                                                    
      end                                                                                                                                                                         
    end          
  </code></pre>
  
  <p>I've tried doing the standard </p>
  
  <pre><code>@packages = Package.all(:include =&gt; :vendor)
  </code></pre>
  
  <p>but Couchrest_model doesn't pull in the vendor information that way...</p>