discourse/discourse — pull request #207 by danneu (2013-02-20 03:48:16+00:00)
Title: validate category user_id presence to match DB constraint.

I added a validation + spec to mirror db constraint.

Before:

``` ruby
category = Category.new(name: "Test Category")

category.valid?
#=> true

category.save
#=> BEGIN
# INSERT INTO "categories" ...
# ROLLBACK
# PG::Error: null value in "user_id" violates not-null constraint.
```

After:

``` ruby
category.valid?
#=> false

category.save
#=> false

category.errors?
#=> { user_id: ["can't be blank"] }
```