Rails 3 - how can I customize a text label in the label helper?

This is probably a little low question, but is there any neat way to change the label text in the helper shortcut ?

= f.label :name 

give rise to

 <input id="car_name" name="car[name]" size="30" type="text"> 

If I wanted to have the text in the label , say, your car instead of Name , how to do it?

One way is to write the tag tag directly as HTML, but it's a little messy ...

+8
ruby-on-rails-3 label helper
source share
1 answer

Just add the second line argument to f.label, for example:

 label_tag 'name', 'Your name' # => <label for="name">Your Name</label> 

Look here

+17
source share

All Articles