module ApplicationHelper def required_label_tag(form, field, text = nil) label_content = text || field.to_s.titleize required = form.object.class.validators_on(field).any? { |v| v.is_a?(ActiveRecord::Validations::PresenceValidator) } form.label field, class: "font-bold" do required ? "#{label_content} *".html_safe : label_content end end end