Skip to content

Instantly share code, notes, and snippets.

@cdimartino
Created February 12, 2016 22:44
Show Gist options
  • Save cdimartino/075f1121590b76be9f79 to your computer and use it in GitHub Desktop.
Save cdimartino/075f1121590b76be9f79 to your computer and use it in GitHub Desktop.
Defense against the dark arts: Database Constraints

The database is our last level of defense against the dark evil data that Users try to feed us. Make sure you don't spoil your pristine data structures by making sure that constraints are present:

create_table :posts do |t|
  t.string :title, null: false
  t.string :content, null: false

  t.timestamps null: false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment