title: Rails, what is the best way to link two models and create one before another
body: <p>I've two models:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    before_create :add_address
    has_one :address
  
  
    def add_address
      self.address_id ||= Address.generate_new.id
    end
  end
  </code></pre>
  
  <p>And</p>
  
  <pre><code>class Address &lt; ActiveRecord::Base
    belongs_to :user
  
    def self.generate_new
      new_address = # some code generating UUID
  
      Address.create!({address: new_address})
    end
  end
  </code></pre>
  
  <p>But when I create User, it saves address, but user_id didn't show on the Address model. I don't want to update Address after creating the User. Maybe I do smth not in a rails way?</p>