Skip to content

Instantly share code, notes, and snippets.

@henrik
Last active December 14, 2015 15:38
Show Gist options
  • Save henrik/5108817 to your computer and use it in GitHub Desktop.
Save henrik/5108817 to your computer and use it in GitHub Desktop.
Un-titlecase submit tag default value. E.g. "Create User" -> "Create user".
# Remove titlecase from submit tag default value.
# E.g. "Create User" -> "Create user".
class ActionView::Helpers::FormBuilder
def submit_default_value_with_titlecase_removal
old = submit_default_value_without_titlecase_removal
model = if object.class.respond_to?(:model_name)
object.class.model_name.human
else
@object_name.to_s.humanize
end
old.sub(model, model.mb_chars.downcase)
end
alias_method_chain :submit_default_value, :titlecase_removal
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment