title: Rails 5: users(devise) and managing multiple tables on a single page
body: <p>I have had this working using Laravel but am attempting to get this together in a Rails app now.</p>
  
  <p>Basically I currently have setup a new Rails app with the following steps:</p>
  
  <ol>
  <li><code>rails new MyApp</code></li>
  <li>Installed devise
  
  <ul>
  <li>Add devise to Gemfile</li>
  <li><code>bundle</code></li>
  <li><code>rails g devise:install</code></li>
  </ul></li>
  <li>Setup custom devise controllers and views
  
  <ul>
  <li><code>rails g devise:controllers users</code></li>
  <li><code>rails g devise:views users</code></li>
  </ul></li>
  <li>Added custom fields for devise user &amp; updated new/edit views</li>
  </ol>
  
  <p>Uptill this point, everything works fine. I am able to login/logout and communicate with database properly.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p><em>First part of my question</em></p>
  
  <p>How to bring in a row relating to the user onto a specific page has been answered by Saqib Shahzad's answer. </p>
  
  <p>For all intensive purposes, I have setup a Home controller and related view that allows me to bring in all the related information.</p>
  
  <p><em>This is the second part</em></p>
  
  <p>Now what I want to do is create a row for the user on a separate table at the same time that the user is created.</p>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ApplicationRecord
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :validatable
  
    has_one :order
  end
  </code></pre>
  
  <p>order.rb:</p>
  
  <pre><code>class Order &lt; ApplicationRecord
    belongs_to :user
  end
  </code></pre>
  
  <p>order migration:</p>
  
  <pre><code>class CreateOrders &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :orders do |t|
        t.belongs_to :user
        ...
  end
  </code></pre>
  
  <p>So, assuming that I am using devise... How, when the user is created, can the necessary row be created in the Orders table so that after registration, they can immediately see their order information. (It would obviously just show the default values of the fields as they did not edit anything yet)</p>
  
  <p>So...</p>
  
  <ol>
  <li>Person fills in registration information on registration page.</li>
  <li>Person clicks submit</li>
  <li>Both users and orders tables are given a new row for the new user (User and the user's Order is created)</li>
  <li>Person is immediately redirected to their homepage that shows them their order values</li>
  </ol>