With twitter-bootstrap-rails installed, using the generator:
rails g bootstrap:themed Model
creates views that contain lines such as:
<th><%= model_class.human_attribute_name(:comment_date) %></th>
<th><%= model_class.human_attribute_name(:comment_time) %></th>
where the default rails generator just inserts the human readable column name directly:
<th>Comment date</th>
<th>Comment time</th>
which makes for cleaner views, and seems like it would be more efficient at run-time.
Is there a benefit to the twitter-bootstrap-rails generated views?
Thanks!
(PS, The developers website is offline, and neither github nor google+ allow sending private messages, and neither an “issue” on github nor a public comment on a google+ post seemed appropriate for this question, so hoping someone here might be familiar with the use-case for model_class.human_attribute_name())
Take a look at its source and things will get clear to you:
human_attribute_namedoes a great job for localizing your attribute names. Even if you’re building app which uses English exclusively — who knows, maybe your inbox already has an email from your client about his plans on expanding business and this expansion will include countries where people write right-to-left.How it works
Assume you have
Productmodel withtitleattribute. Callinghuman_attribute_namethis way:will call
I18n.t(see the last line in the snippet above) with the following parameters:So, you can provide translations specific to some model and specific to some attribute’s name. Unless you provide any of these translations you’ll get English version of your attribute created via
humanizemethod.