Skip to content

Instantly share code, notes, and snippets.

@wuputah
Created October 1, 2008 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuputah/14000 to your computer and use it in GitHub Desktop.
Save wuputah/14000 to your computer and use it in GitHub Desktop.
has_fields plugin
module HasFields
def has_any?(*fields)
fields.each { |f| return true unless self.send(f).blank? }
false
end
def has_all?(*fields)
fields.each { |f| return false if self.send(f).blank? }
true
end
end
ActiveRecord::Base.send!(:include, HasFields)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment