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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:35:05+00:00 2026-06-07T19:35:05+00:00

New ROR programmer here. I’m trying to build a web application that allows a

  • 0

New ROR programmer here. I’m trying to build a web application that allows a user to complete a form, where they enter a companies information, and by clicking submit, it adds the input to a database.

At the moment, if the user was to create a new entry, they would see a few fields, for example, "Company Name". There is a blank box for them to put in a new company, and next to that, there is a drop down menu that the user can use to see existing companies in the database.

<div class="field">
<%= f.label :company_name %><br />
<%= f.text_field :company_name %>
<%= f.label :company_name %><br />
<%= f.select( :company_name, Company.all.map {|p| [p.company_name]}.uniq!, :prompt => "Select a Company") %>

I’m looking for a way to allow the user to enter a new company, OR click on the drop down menu and select an existing company.

At the moment:
If nothing is entered into textbox and no option from dropdown selected, it is saved as blank.
If something is entered, and no option is selected, it is saved as blank.
However, if something is entered and something is picked from the dropdown, the dropdown option is saved.

Hopefully I haven’t made it too confusing. Any help at all will be appreciated.

Thanks in advance.

EDIT:

My create action now looks like this

 def create
@company = Company.new(params[:company])
@company.company_name = params[:new_company_name] unless params[:new_company_name].empty?

respond_to do |format|
  if @company.save
    format.html { redirect_to @company, notice: 'Company was successfully created.' }
    format.json { render json: @company, status: :created, location: @company }
  else
    format.html { render action: "new" }
    format.json { render json: @company.errors, status: :unprocessable_entity }
  end
end

end

and form view:

<%= label :company_name %><br />
<%= text_field :new_company_name %>

<%= f.label :company_name %><br />
<%= f.select( :company_name, Company.all.map {|p| [p.company_name]}.uniq!, :prompt => "Select a Company") %>

The new error is now:

wrong number of arguments (1 for 2)

Extracted Source:
<%= label :company_name %>

  • 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-07T19:35:08+00:00Added an answer on June 7, 2026 at 7:35 pm

    You cannot have two params with the same name in your view, as rails won’t know what to do with them

    @rodzyn is right, so please give the credits to him.. 🙂

    Just to clarify:

    your form:

    <%= label_tag :new_company_name, "Company name" %><br />
    <%= text_field_tag :new_company_name %>
    
    <%= f.label :company_name %><br />
    <%= f.select( :company_name, Company.all.map {|p| [p.company_name]}.uniq!, :prompt => "Select a Company") %>
    

    Your controller:

    @company = Company.new(params[:company])
    @company.company_name = params[:new_company_name] unless params[:new_company_name].empty?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to RoR and I'm trying to create a web application that acts
I am new to RoR and I am trying to build simple web application
I'm very new to RoR, and am trying to implement a user login system.
i'm new with RoR and i'm trying to make a master-datail: User -Lugar(place) My
I am a RoR programmer new to Python. I am trying to find the
I am new to ROR. I am trying add translations to my application. I
I have an almost new setup of ROR 3.1 here and have already generated
I'm completely new to Ruby (and RoR) and I'm trying to set up a
I'll preface this with the fact that I'm new to RoR. I have a
I'm new to RoR and I'm trying to test my app. In my sample

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.