Skip to content

Instantly share code, notes, and snippets.

@qrush
Created December 27, 2010 17:04
Show Gist options
  • Save qrush/756299 to your computer and use it in GitHub Desktop.
Save qrush/756299 to your computer and use it in GitHub Desktop.
%w[address_1 city state zip_code].each do |attr|
validates_presence_of attr, unless: ->(org) { org.send(attr).nil? }
end
@jamesarosen
Copy link

This may have been removed in Rails 3, but in 2.3 I would have done this as

validates_presence_of :address_1, :city, :state, :zip_code, :allow_blank => true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment