ruby on rails - human attribute name in a partial for a form_for -


i have shared partial i'm using in various form_for tags so:

<%= render 'shared/text_field_attribute', :f => f, :attribute => :some_attr, :predicate => 'is/starts with/ends with/etc.' %> 

app/views/shared/text_field_attribute.html.erb looks this:

<div class="form-group">   <%= f.label attribute, "#{attribute} #{predicate}", class: 'sr-only' %>   <%= f.text_field attribute, class: 'form-control', placeholder: "#{f.object.class.human_attribute_name(attribute)} #{predicate}…" %> </div> 

is there more concise human attribute name?

f.object.class.human_attribute_name(attribute) 

instead of:

f.object.class.human_attribute_name(attribute) 

you can use humanize method so:

attribute.to_s.humanize 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -