Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:29:48+00:00 2026-06-05T11:29:48+00:00

With twitter-bootstrap-rails installed, using the generator: rails g bootstrap:themed Model creates views that contain

  • 0

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())

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:29:49+00:00Added an answer on June 5, 2026 at 11:29 am

    Take a look at its source and things will get clear to you:

    # File activemodel/lib/active_model/translation.rb, line 45
    def human_attribute_name(attribute, options = {})
      defaults  = []
      parts     = attribute.to_s.split(".", 2)
      attribute = parts.pop
      namespace = parts.pop
    
      if namespace
        lookup_ancestors.each do |klass|
          defaults << :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}/#{namespace}.#{attribute}"
        end
        defaults << :"#{self.i18n_scope}.attributes.#{namespace}.#{attribute}"
      else
        lookup_ancestors.each do |klass|
          defaults << :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}"
        end
      end
    
      defaults << :"attributes.#{attribute}"
      defaults << options.delete(:default) if options[:default]
      defaults << attribute.humanize
    
      options.reverse_merge! :count => 1, :default => defaults
      I18n.translate(defaults.shift, options)
    end
    

    human_attribute_name does 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 Product model with title attribute. Calling human_attribute_name this way:

    Product.human_attribute_name 'title'
    

    will call I18n.t (see the last line in the snippet above) with the following parameters:

    I18.t 'activerecord.attributes.product.title', {
      :count=>1, 
      :default=>[:"attributes.title", "Title"] 
    }
    

    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 humanize method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In attempting to upgrade to Bootstrap 2 (using twitter-bootstrap-rails gem), it seems that page-specific
I am using Twitter Bootstrap in my rails app. My navbar looks perfect in
I'm asking about using a Twitter Bootstrap modal window with a Rails form helper
Hey so I am using Rails PJAX for my web application with twitter bootstrap
I'm working with a project that uses twitter-bootstrap-rails. This project was built on a
I'm using Twitter Bootstrap 2.0.1 in a Rails 3.1.2 project, implemented with bootstrap-sass. I'm
In my Rails 3 application I'm using Twitter Bootstrap as a frame work for
I recently installed Twitter Bootstrap in my Rails app via the following two steps:
I am using Twitter Bootstrap as Css framework and thinking why waste that space
How to use custom variables when using twitter-bootstrap-rails gem? I want to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.