Rails throwing ActiveRecord::StatementInvalid PG::NotNullViolation: ERROR

660 views Asked by At

I recently added bootstrap-datepicker-rails. Now when I try to save a record and I do not enter a date, I receive the active record error above. I have validations set up - why wont it throw a more user friendly error? How can I get this to provide a user friendly error? I am using rails 4.2.7 and ruby 2.3.1.

1

There are 1 answers

1
Deepak Mahakale On

The problem is you have only added database level not null validation.

Add model level validation as well and you will get well formatted error message

validates :date, presence: true