I have an object that whose values are all caps, and I would like the f.label
helper to print it out as all caps - without having to do a CSS transform.
Right now, if I have the string AAPL
in my object, f.label
spits it out as Aapl
.
The reason I don't want to use a CSS transform is because the value of the object will not ALWAYS need to be all uppercase. I just want the f.label
to output it exactly as it is stored in the db - preferably without any CSS shenanigans.
How do I do that?
It sounds like something is calling humanize()
. This seems to happen, when Rails translates an element name to a label title. Probably you should define the text for the label explicit to it's form element.
<%= f.label(:aapl, 'AAPL') %>
or even
<%= f.label(:aapl, @yourVar) %>
Another option for you might be the translation ability, which Rails provides. This is valid for Rails > 3.1!
In your view:
<% form_for @post do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.submit %>
<% end %>
In your en.yml:
en:
helpers:
label:
post:
title: 'Your Title'
Try this:
f.label(topic).upcase.html_safe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With