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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:36:35+00:00 2026-06-02T21:36:35+00:00

tried to create simple dropdown in ruby with values from the database – like

  • 0

tried to create simple dropdown in ruby with values from the database – like that :

<% ingredientArray = Ingredient.all.map { |ingredient| [ingredient.name, ingredient.id] } %>
<div class="field">
  <%= select_tag(:ingredient_id, ingredientArray) %><br/>
</div>

and I received an empy one.
this is the generated html

<div class="field">
   <select id="ingredient_id" name="ingredient_id">[[&quot;Paprika&quot;, 5], [&quot;Cinnamon&quot;, 8], [&quot;Salt&quot;, 9], [&quot;Pepper&quot;, 10], [&quot;water&quot;, 11]]</select><br/>
</div>

where should I put html sage

  • 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-02T21:36:36+00:00Added an answer on June 2, 2026 at 9:36 pm

    You should read documentation on select_tag and related methods.
    The second parameter of it is a string containing the option tags for the select box.
    You can generate in manually:

    select_tag "people", "<option>David</option>".html_safe
    

    Or use options_from_collection_for_select method for it:

    select_tag "people", options_from_collection_for_select(@people, "id", "name")
    

    (Examples from the docs)

    Specifically in your case the best way to make that dropdown is:

    <div class="field">
        <%= select_tag("Ingredients", options_from_collection_for_select(Ingredient.all, 'id', 'name')) %>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

tried to create simple dropdown in ruby - like that : <%= select_tag(:origin_id, '<option
I want to create simple charts like pies and bars in python. I tried
I have a simple form that has a list (dropdown list generated from a
Im a newcommer in ASP.NET (Switched from Java/PHP) And tried to create a simple
I'm new to cakePHP.I just tried to create a simple form with a text
I've got a simple dropdown menu that I want to hide whenever you click
I'm trying to create simple DER decoder - console application that just outputs content
I tried to create a simple ComboBox: var combo1 = new Ext.form.ComboBox({ store: [1,2,3],
I am new to Spring and Hibernate. I tried to create a simple application
I am trying to create a simple matcher that matches any string consisting of

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.