title: Rails 3 has_one / belongs_to relationship with model in subdirectory
body: <p>I'm trying to create a simple relationship but with a model in a subdirectory under Rails 3.2</p>
  
  <p>I have a User class and each user has an email subscription..  Because There will be other types of subscriptions (which also fill be added to users) I put them in a subdirectory .  (My User happens to come from Devise but I suspect that won't matter.)</p>
  
  <p>Here's the code</p>
  
  <p>In <code>model/user.rb</code></p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_one :email_sub
  
    before_create :build_email_subscription
  
    private
  
    def build_email_subscription
      Subscription::EmailSub.create(:is_subscribed =&gt; true, :user_id =&gt; self.id)
      true
    end
  end
  </code></pre>
  
  <p>Note that I have also created a way to add a default subscription.</p>
  
  <p>In <code>model/subscriptions/email_sub.rb</code></p>
  
  <pre><code>class Subscriptions::EmailSub &lt; ActiveRecord::Base
    belongs_to :user
  end
  </code></pre>
  
  <p>In addition to the migrations to create the two classes I created the following migration for the relationship.</p>
  
  <pre><code>class AddSubscriptionToUser &lt; ActiveRecord::Migration
    def change_table :subscriptions_email_sub do |t|
      t.referneces :users
    end
  end
  </code></pre>
  
  <p>However, this doesn't seem to be working. It doesn't seem to be generating the <code>user_id</code> column.</p>