Skip to content

Instantly share code, notes, and snippets.

@Wardrop
Created March 27, 2012 11:08
Show Gist options
  • Save Wardrop/2214994 to your computer and use it in GitHub Desktop.
Save Wardrop/2214994 to your computer and use it in GitHub Desktop.
# Current Validation Strategy
validates_presence :place_id
errors.add(:place, "must have a parent") unless place.parent_id
# Improved Validation Strategy
validates_presence :place_id
validates :place, "must have a parent" { place.parent_id }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment