title: A has_many Bs where B has no primary key
body: <p>I've got models A and B; A has_many B, and B belongs_to A.  So far, so good—except, I specify that B doesn't have a primary key. I don't plan to ever modify or delete individual B rows, and I expect to have several million to billion of them, so omitting the primary key will be really handy, space-wise.</p>
  
  <p>The migration to create B's table looked like this:</p>
  
  <pre><code>class CreateBs &lt; ActiveRecord::Migration
    def change
      create_table :bs, {:id =&gt; false} do |t|
        # … rest of fields …
      end
    end
  end
  </code></pre>
  
  <p>Unfortunately, ActiveRecord disagrees; trying to create an A (that's right!) results in:</p>
  
  <pre><code>1.9.3p194 :001 &gt; A.create!
     (0.3ms)  BEGIN
     (0.1ms)  ROLLBACK
  ActiveRecord::UnknownPrimaryKey: ActiveRecord::UnknownPrimaryKey
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/reflection.rb:366:in `primary_key'
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/reflection.rb:216:in `association_primary_key'
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/has_many_association.rb:104:in `foreign_key_present?'
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association.rb:165:in `find_target?'
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/collection_association.rb:332:in `load_target'
          from /Users/annelicuss/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/collection_proxy.rb:44:in `load_target'
  …
  </code></pre>
  
  <p>If you catch the exception, its <code>message</code> states:</p>
  
  <pre><code>"Unknown primary key for table bs in model B." 
  </code></pre>
  
  <p>(which would be because B has no primary key.)</p>
  
  <p>I'd like to not have this issue! Is there any way?</p>