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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:35:38+00:00 2026-06-13T22:35:38+00:00

I created a simple model called Categories, which is connected to Platforms model. class

  • 0

I created a simple model called Categories, which is connected to Platforms model.

class Platform < ActiveRecord::Base
    attr_accessible :name, :url, :country, :categories
   belongs_to  :category
end

and

class Category < ActiveRecord::Base
  attr_accessible :name
  has_many :platforms
end

I also successfully have form for creating new Platforms :

<%= simple_form_for(@platform) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :name %>
    <%= f.input :url %>
    <%= f.input :country %>
    <%= f.label :category %>
    <%= f.collection_select(:category_id, @categories, :id, :name, :include_blank => "Please select") %>
  </div>

  <div class="form-actions">
    <%= f.button :submit %>
  </div>
<% end %>

Unfortunately ,since model Category is new, dropdown currently has only 1 value “Please selected”. How do I add new values to this select, preferably via the model?

  • 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-13T22:35:39+00:00Added an answer on June 13, 2026 at 10:35 pm

    Note that with simple_form, you can automatically generate the drop-down using

    <%= f.association :category %>
    

    This will automatically populate the list with categories from the database. See the documentation for more tips.

    EDIT:
    Categories simply have to be added separately. You can either manually seed your database with categories with the db/seeds.rb script or through the rails console. Or you can allow users to add categories through a separate form and controller.

    For example, to create a few categories in the console, run rails c from the command line and run Category.create!(name: "Name") for a few names.

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

Sidebar

Related Questions

I've created a simple Project model with four attributes: Project name:string description:text complete:boolean user_id:integer
Hello I`ve created simple WFC DataService and connected entit model with my database. This
I have created a very simple model called Discussion and one of the columns
I have created a simple state machine model in Enterprise Architect and exported it
I created a custom view that uses Json.Simple to serialize the model and write
Simple. I created a LINQ-TO-SQL Entity model, created a website, added a Data Service
I've created a simple 'favourites' system in my django app. I have events which
I have a very simple user model. When I first created it, it had
I have created a simple application which has a red background and a button
I'm writing a simple Rails model called Person that has_many :phone_numbers and I'm trying

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.