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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:27:52+00:00 2026-06-15T13:27:52+00:00

I have a Model Startup and I have a other Model Categorie. The two

  • 0

I have a Model “Startup” and I have a other Model “Categorie”. The two tables are associated.

I’d like call the data of Categoria through to form of Startup, this categories displayed with a checkbox. Inside the form Startup Form I have the categorie_id. This is the code

<%= form_for(@startup) do |f| %>
  <% if @startup.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@startup.errors.count, "error") %> prohibited this startup from being saved:</h2>

      <ul>
      <% @startup.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </div>
  <div class="field">
    <%= f.collection_select :round_id, Round.order(:name), :id, :name, include_blank: true %>
  </div>
  <div class="field">
    <%= f.label :category %><br />
    <%= f.text_field :category_id %>
  </div>

  <div class="field">
    <%= f.collection_select :country_id, Country.order(:name), :id, :name, include_blank: true %>
  </div>


  <div class="actions">
    <%= f.submit %>   </div> <% end %>

How to display the data of Categories within form with a checkboxs ?

Any idea.

pdt: My english is really bad.

  • 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-15T13:27:53+00:00Added an answer on June 15, 2026 at 1:27 pm

    If a Startup can have only one Category, you can do like this in your view:

    <div class="field">
      <%= f.label :category %><br />
      <%= f.collection_select :category_id, Category.all, :id , :name %>
    </div>
    

    This will output a dropdown menu with all the categories. Make sure that the Category model has the attribute name.

    As you said, a Startup belongs to one Category, so using radiobuttons (checkboxes are here for multiple relation, means you could choose multiple categories):

    <div class="field">
      <% Category.all.each do |category| %>
        <%= f.radio_button :category_id, category.id %>
        <%= f.label :category_id, category.name %>
      <% end %>
    </div>
    

    You may have to add <br /> tags, and html options to make it looks better.

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

Sidebar

Related Questions

I have model like this: scope :search_posts, lambda { |query| mega_posts.where( title LIKE ?
I have a relationship belongs_to to belongs_to between two model in rails. I have
I have a code-first EF model based on 4.3.1. In this model there is
I have model with a location, which itself has a latitude and longitude. What
I have model Foo which has field bar. The bar field should be unique,
I have model Article it has field title with some text that may contain
I have model public class UploadOptionModel { public UploadOptionModel() { OutputFormat = outputFormatList.Select(i =>
I have model: [XmlRoot(ElementName = event, IsNullable=true)] public class Event { public int id
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
Lets say I have model inheritance set up in the way defined below. class

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.