Skip to content

Instantly share code, notes, and snippets.

@maker-leo
maker-leo / question.rb
Created April 11, 2013 14:41
How to find all questions where the answers user_id IS NULL
includes(:answers)
.where("user_id IS NULL OR user_id != ?", user_id)
# Shoulda activemodel cheatsheet
# DB
should have_db_column(:title).of_type(:string).with_options(default: 'Untitled', null: false)
should have_db_index(:email).unique(:true)
# Associations
should belong_to :company
should have_one(:profile).dependent(:destroy)
should have_many(:posts).dependent(:nullify)