-1

How do you get a Rails label to use the titelize format so that instead of getting "To date" I would get "To Date"

label_tag 'To Date'

displays 'To date'since Rails defaults to human readable formatting.

Steve
  • 2,596
  • 26
  • 33
  • possible duplicate of [Custom text for rails form\_for label](http://stackoverflow.com/questions/13003626/custom-text-for-rails-form-for-label) – Brad Werth Aug 12 '15 at 01:28
  • Or you could use a custom form builder, which isn't covered in the referenced link. – Brad Werth Aug 12 '15 at 01:28
  • I updated the title to specify that this was for a label_tag which isn't covered by the question you mentioned – Steve Aug 12 '15 at 03:08
  • @BradWerth, I added one solution, not sure why down voted, instead of knocking for not showing a custom form builder, you can add as another answer – Steve Aug 12 '15 at 03:15
  • OK, http://stackoverflow.com/questions/10473565/rails-3-how-can-i-customize-text-label-in-label-helper then... This is a dupe of dozens of existing questions, and your answer is the least idiomatic way to do it, which is probably why you were downvoted. I am not inclined to answer trivial dupes. – Brad Werth Aug 12 '15 at 03:28

1 Answers1

-1
label_tag('to_date', 'To Date', class: 'control-label')

displays 'To Date' with html of:

<label for="to_date">To Date:</label>

[Per the documentation:][1]

label_tag(name = nil, content_or_options = nil, options = nil, &block)

Steve
  • 2,596
  • 26
  • 33