In my Rails 3.2 project, I have a form to create a new post in new.html.erb in app/views/posts/
<%= form_for(@post) do |post_form| %>
...
<div class="field">
<%= post_form.label :title %><br />
<%= post_form.text_field :title %>
</div>
...
<div class="actions">
<%= post_form.submit %>
</div>
<% end %>
I want to display the title label as TITLE, so I changed the code to post_form.label :TITLE %>, but it still displays Title. How can I display it as TITLE?
Since this is a matter of presentation on screen as opposed to content, rather than do the transformation in eruby code, this really ought to be done in CSS:
If you only want to modify the
:titleinput’s label rather than all labels having the same class, add a different class or use the input’s id in the CSS rule.If you insist on up-casing it in Rails, use the second parameter to
.label: