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
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
or use select – http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select
you might want to specify a case sort if your db is case sensitive