In Rails 5, whenever we define a belongs_to association, it is required to have the associated record present by default after this change. It triggers validation error if associated record is not present. 1 2class User < ApplicationRecord 3end 4 5class Post < ApplicationRecord 6 belongs_to :user 7end 8 9post = Post.create(title: 'Hi') 10=> <Post id: nil, title: "Hi", user_id: nil, created_at: nil
![Rails 5 makes belongs_to association required by default](https://cdn-ak-scissors.b.st-hatena.com/image/square/df7dcf3e382d2d4b018ba79fc6642260e3fa7070/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fdpc4i4bdx%2Fimage%2Fupload%2Fbigbinary_blogs%2Fdefault_blog_image.png)