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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:18:45+00:00 2026-05-30T22:18:45+00:00

to be honest, I almost find html forms more straightforward than Rails form helpers.

  • 0

to be honest, I almost find html forms more straightforward than Rails form helpers. I’m trying to turn this text form into a select box with options Canada, United States, Mexico as strings

 <p><%= f.label :country %><br />
  <%= f.text_field :country %></p>

Because the model is already represented in the block variable “f”, I’m not sure how to alter the syntax because the model is usually represented first in the complicated hash of variables and options http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select

Can anyone show me?

  • 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-05-30T22:18:47+00:00Added an answer on May 30, 2026 at 10:18 pm

    The following should work:

    <%= f.select :country, [["Canada", "Canada"], ["Mexico", "Mexico"], ["United States", "United States"]] %>
    

    You can read more in the Rails Guides & API docs. As @ka8751 says, though, if you have a Country model, collection_select makes this far easier:

    <%= f.collection_select :country, Country.all, :id, :name %>
    

    where :id is used for the actual value of the <option> tag and :name is used for what is displayed.

    If you don’t have a Country model, you should consider one for the sake of database normalization.

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

Sidebar

Related Questions

(This looks like a long question, but it's not really, honest!) I am trying
Honest, I am really trying to learn this stuff. I've been using Classic ASP
I'm going to be honest: this is a question I asked on the Django-Users
I have found that my HTML is, to be honest, very clunky. Small, simple
License keys are the defacto-standard as an anti-piracy measure. To be honest, this strikes
So I'll be honest, this is for a homework assignment. I know how to
This is just to keep honest customer honest.
To be honest, I'm feeling pretty stupid right now. But this simply isn't working
To be honest, I actually have a solution for this, but Google search finds
Well, to be honest this is actually my homework where I have to implement

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.