Module: Rails::MarkRequirements::ClassMethods
- Defined in:
- lib/rails/mark_requirements.rb
Instance Method Summary collapse
-
#mark_required?(attribute) ⇒ Boolean
:call-seq: Klass.mark_required? :attribute.
Instance Method Details
#mark_required?(attribute) ⇒ Boolean
:call-seq: Klass.mark_required? :attribute
does field_for(object.attribute) require ‘a presence’
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 |