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 8786171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:32:55+00:00 2026-06-13T21:32:55+00:00

I am implementing a view count feature for particular web pages in Ruby on

  • 0

I am implementing a view count feature for particular web pages in Ruby on Rails. I use haml lists to achieve my end. (The JavaScript library takes the list and render it as dropdowns.)

Here is the code snippet:

%li.action
  = link_to t(question.views_count.to_s + ' views')

My problem here is that the V in views is capitalized in the output and view is pluralized even for 0 and 1 number of views. Is there any way I can deal with these issues?

  • 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-13T21:32:56+00:00Added an answer on June 13, 2026 at 9:32 pm

    You’re doing it wrong, you should be letting the I18N system (i.e. the t method) deal with the pluralization on its own. Proper plural handling is horribly complicated, don’t try to do it yourself with string manipulation. You’re using the t method but it can do a lot more for you.

    From the I18N Guide:

    The :count interpolation variable has a special role in that it both is interpolated to the translation and used to pick a pluralization from the translations according to the pluralization rules defined by CLDR:

    I18n.backend.store_translations :en, :inbox => {
      :one => '1 message',
      :other => '%{count} messages'
    }
    
    I18n.translate :inbox, :count => 2
    # => '2 messages'
    

    So assuming you have your message database properly set up, then you would do something like this:

    t(:views, :count => question.views_count)
    

    And your English translation file would have something like this:

    views:
      one: "1 view"
      other: "%{count} views"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the Rails way of implementing a view for a data model that
In my applications I always end up implementing a Model-View-Presenter pattern and usually end
I am implementing a feature that displays a 360 degree view of a product.
I am implementing in Ruby on Rails, and i want to do so, that
I am implementing in Ruby on Rails, and i have 2 views. In my
I am implementing view controllers that shall have different behaviour. They have a common
I'm looking for the Android way of implementing a modal view which interrupts the
I'm implementing an OnTouchListener on a custom view. In this view I'm drawing an
My view controller is getting a little large for me. I'm implementing five delegate
Suppose I'm implementing an MVP pattern and I have a view interface as such:

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.