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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:49:38+00:00 2026-05-22T02:49:38+00:00

I am using Rails 3 and I am having a problem. My collection_select is

  • 0

I am using Rails 3 and I am having a problem. My collection_select is not populating the field in the DB. This is what my view looks like: (some html was removed)

f.label "Company Name"
@c = Company.all
collection_select(:Company , :company_id, @c, :id , :companyName, {:prompt => true})   
f.submit

The drop down list has the correct values, but when I submit it, this is what my params looks like: "Company"=>{"company_id"=>"2"}. I don’t have a field called company, but I do have a field called company_id and a table called company. Is my syntax correct?

Processing by RecordsController#create as HTML

Parameters: {"utf8"=>"✓", "authenticity_token"=>"WLzwCoZFCUhyH9ZqYWYLmaQwyleB3JLoTnb4lhftKzc=", "record"=>{"title"=>"test", "Company"=>{"company_id"=>"2"}, "commit"=>"Create record"}

AREL (2.0ms)  INSERT INTO "records" ("company_id", "title", "created_at", "updated_at") VALUES (NULL, 'test','2011-05-17 05:01:38.905717', '2011-05-17 05:01:38.905717')
Redirected to http://localhost:3000/Records/7
Completed 302 Found in 150ms
  • 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-22T02:49:39+00:00Added an answer on May 22, 2026 at 2:49 am

    Try this

    # in controller
    @companies = Company.all
    
    collection_select @record, :company_id, @companies, :id, :companyName
    

    or

    form_for @record do |f|
      = f.collection_select :company_id, @companies, :id, :companyName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problem uploading image to mongodb using rails and carrierwave. This is
I'm using Jquery with Ruby on Rails (3.1) and am having some problem with
I'm using rails in action , but I'm having a problem with this scenario.
I'm having some problem with this code using the #as_json method. render json: channel.as_json({
I'm currently using capistrano to deploy my project. However I'm having this problem below:
I am having some issues with nested models in a form, using Rails 3.1rc4.
i developed a project using Ruby on Rails and i having a huge problem
I'm having some issues using rails validation on a form. What I'm doing is,
I am using capistrano in a rails-less environment and I'm having a problem with
please help with this using rails 3 and jquery-ui. In my view i have:

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.