diff --git a/lib/bootstrap_form/components/labels.rb b/lib/bootstrap_form/components/labels.rb index 240558e2f..64caa7d5a 100644 --- a/lib/bootstrap_form/components/labels.rb +++ b/lib/bootstrap_form/components/labels.rb @@ -48,7 +48,7 @@ def label_text(name, options) if label_errors && error?(name) (options[:text] || object.class.human_attribute_name(name)).to_s.concat(" #{get_error_messages(name)}") else - options[:text] || object.class.human_attribute_name(name) + options[:text] || object&.class&.human_attribute_name(name) end end end