I wrote an article about points that I personally want to be aware of when writing validation code in the model.
Post.rb
validates :user_id, {presence: true} ⬆︎ Be sure to put a comma!
Recommended Posts