title: Rails has_one with class name and foreign key
body: <p>I have a Rails model which I use two <code>has_one</code> relations: <code>requester</code>and <code>friend</code>. When in the console I use:</p>
  
  <pre><code>f = FriendRequest.all
  f[0].requester
  </code></pre>
  
  <p>I get <code>ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: users.requester_id: SELECT  "users".* FROM "users"  WHERE "users"."requester_id" = 4 LIMIT 1</code>
  . </p>
  
  <p>I don't really know how to specify a `has_one' relationship with a class name and a key which specifies the record. This is my model:</p>
  
  <pre><code>class FriendRequest &lt; ActiveRecord::Base
    has_one :requester, :class_name =&gt; "User", :foreign_key =&gt; "requester_id"
    has_one :friend, :class_name =&gt; "User", :foreign_key =&gt; "friend_id"
  end
  </code></pre>
  
  <p>How could I do it? In a <code>belongs_to</code> relationship I use the same, obviously replacing <code>has_one</code>with <code>belongs_to</code>. Thanks!</p>