[Ruby] [Rails] Where you want to be careful in the description of validation

less than 1 minute read

I wrote an article that I would like to personally take care when writing validation code in the model.

If you use {} when setting validates in # model, be sure to put a comma immediately after the column name!

Post.rb


validates :user_id, {presence: true}
                   ⬆︎
Be sure to put a comma!