Module: UniqueGenerator::UniqueChecks::MM
- Defined in:
- lib/unique_generator.rb
Instance Method Summary collapse
-
#unique_field?(field_name) ⇒ Boolean
Returns whether or not the given field is unique to every item.
Instance Method Details
#unique_field?(field_name) ⇒ Boolean
Returns whether or not the given field is unique to every item.
26 27 28 29 30 |
# File 'lib/unique_generator.rb', line 26 def unique_field?(field_name) scope = self.class.where(field_name => send(field_name)) scope = scope.where(:_id.ne => id) if id.present? scope.empty? end |