To my knowledge, the new default in Rails 5 requires belongs_to
associations to be present. I made a model with this association, but the problem is I don't get presence validation error when the associated field is empty. Instead I get a database Null Validation error since I set the _id
column not to be null. (PG::NotNullViolation because I use Postgres)
Is this behaviour normal? I mean shouldn't I get the rails error only?
BTW, when I add presence validation for the field, it works as I expected.
config.load_defaults 5.1
is in your application.rb, which is the default for new generated apps (reference) – Centenarian