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

  • Home
  • SEARCH
  • 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 8062337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:37:58+00:00 2026-06-05T10:37:58+00:00

In a Rails app, I’m trying to format a value in a select tag.

  • 0

In a Rails app, I’m trying to format a value in a select tag.

Something like

<%= f.collection_select(:country_id, Country.order(:name), :id, :name.to_s.downcase) %>

The downcase method is not having any effect. Should I be able to use it in this way? If not, what should I be doing?

Thanks

  • 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-05T10:38:00+00:00Added an answer on June 5, 2026 at 10:38 am

    You can add a method to your model and put in a symbol for that

    see http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select

    class Country
      def name_to_lower
        self.name.downcase
      end
    end
    
    <%= f.collection_select(:country_id, Country.order(:name), :id, :name_to_lower) %>
    

    or use select – http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select

    <%= f.select(:country_id, Country.order(:name).map {|x| [x.name.downcase, x.id] } %>
    

    you might want to specify a case sort if your db is case sensitive

    <%= f.select(:country_id, Country.order("UPPER(name)").map {|x| [x.name.downcase, x.id] } %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Rails app is hosted on Heroku. I would like to have another server
My rails app talks to a couple different APIs, and I'd like to write
For a Rails app, I would like to overload or modify Kernel::load such that
Simple rails app using Postgres DB, getting 'integer out of range' error when trying
My Rails app creates a handful of very simple landing pages and I'd like
On my rails app I have a list of items (like a task list)
My rails app has a user model that has a HABTM relationship with interests
My Rails app has some pages which are SSL-required and others which are SSL-optional.
A rails app I'm working on features examples of quadratic equations. Obviously, these are
My rails app crashes as soon as I access a web page. My versions

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.