Is there anything we can add to the migration below so that Post
s are guaranteed to have referential integrity (meaning a post
's user_id
will always point to a user
row that actually exists in the database)?
class AssociatePostsWithUsers < ActiveRecord::Migration
def change
add_column :posts,
:user_id,
null: false,
index: true
end
end