mjswartz
mjswartz

Reputation: 743

Rails form label capitalization issue

In the show view of my user controller, I'm having an issue with the user's name not being capitalized in a label tag. The code is

<%= form_for(@user) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>

  <%= f.label "Assign " + @user.name + " to" %>
  <%= f.collection_select :id, @ders, :id, :name %>
<% end %>

The user's name appears something like Example User outside of the form_for block when called with @user.name, but inside the block it appears as example user. Why is that?

Upvotes: 2

Views: 809

Answers (1)

CWitty
CWitty

Reputation: 4526

Try changing to <%= f.label :id, "Assign #{@user.name} to" %>, :id is the value used for the for property on the label.

Upvotes: 3

Related Questions