title: Rails - how to make association between these models (not based on "id", but on "email")
body: <p>I have these models that obviously have more attributes, but for simplicity I kept them just like this:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :subs, :foreign_key =&gt; :email, :class_name =&gt; "subs"
  end
  class Subscription &lt; ActiveRecord::Base
    belongs_to :plan
    belongs_to :user
  end
  </code></pre>
  
  <p>In the table <code>subscriptions</code>, there's a column called <strong>email</strong>. This column points to the table <strong>users</strong> where matches an email address of a single user (the column <code>email</code> is in both tables unique).</p>
  
  <p>I would need to create an association between these two models based on the <code>email</code> value. But when I try to run this query (and to get all subscription for the currently sign in user):</p>
  
  <pre><code>&lt;%= current_user.subs.inspect %&gt;
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>uninitialized constant User::subs
  </code></pre>
  
  <p>I'd like to ask you guys for helping me with this association.</p>
  
  <p>Thanks</p>