Generate Rows And Columns from Rails Console
<p>I have a small predicament.</p>

<p>I have a table called users. The table users has relationship with another table called user notification. Here is the migration for the user table:</p>

<pre><code>create_table "user_notifications", force: :cascade do |t|
    t.belongs_to :user
    t.integer "other_user"
    t.integer  "unseen_count",    default: 0
    t.datetime "created_at",                  null: false
    t.datetime "updated_at",                  null: false
  end
</code></pre>

<p>The problem is that when I create a new user then the table is populated with the row of the new user. How do I add the row to all the existing users. It is needed for the function of the app. Also I am using putty to connect to the server so the only tool I have is the rails console.</p>

<p>Example: I have 60 users. How do I have it so all 60 users get a row in the new table using the rails console. </p>

<p>Edit: This is the method I use whenever a user is signed up. Can I use this method within the rails console or create a deviation of this?</p>

<p>user.rb:</p>

<pre><code>after_create :create_user_notification    

def create_user_notification
  UserNotification.create(:user_id =&gt; self.id)
end
</code></pre>

<p>Thank you in advance. </p>