Refactor a handful more models

Group attribute constraints by attribute, and update some database
queries for Rails 4.