Created
October 1, 2008 01:12
-
-
Save wuputah/14000 to your computer and use it in GitHub Desktop.
has_fields plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.send!(:include, HasFields) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment