Module: Rails::MarkRequirements::ClassMethods

Defined in:
lib/rails/mark_requirements.rb

Instance Method Summary collapse

Instance Method Details

#mark_required?(attribute) ⇒ Boolean

:call-seq: Klass.mark_required? :attribute

does field_for(object.attribute) require ‘a presence’

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/rails/mark_requirements.rb', line 18

def mark_required?(attribute)
  validation_classes = self.validators_on(attribute).map(&:class)
  ret = false
  ret = true if validation_classes.include?(ActiveModel::Validations::PresenceValidator)
  ret
end