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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:43:37+00:00 2026-05-16T01:43:37+00:00

Today is the first day I’m looking into Ruby on Rails, and now I’m

  • 0

Today is the first day I’m looking into Ruby on Rails, and now I’m stuck. I have two scaffolds, artist and song.

In songs/new.html.erb, I have these lines:

...
<%= f.label :name %><br />
<%= f.text_field :name %>
...
<%= f.label :Artist %>
<%= collection_select(:song, :Artist, @artists, :id, :sort_name) %>
...

In the form for creating a new song, I want a <select> list with all artists. Using the code above works fine. The form is created as I want it, and the artists are listed. However, when submitting the new song, I get this error:

Artist(#69916999335860) expected, got String(#69917057438720)

The generated HTML code for the select looks like this:

<select id="song_Artist" name="song[Artist]">
  <option value="1">Vreeswijk, Cornelis</option>
  <option value="2">De lyckliga kompisarna</option>
  <option value="3">Wiehe, Mikael</option>
  <option value="4">Demian, Lars</option>
  <option value="5">Sundström, Stefan</option>
</select>

I guess the second last parameter for collection_select() is wrong, but what should it be?

  • 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-16T01:43:37+00:00Added an answer on May 16, 2026 at 1:43 am

    I think this should be:

    <%= collection_select(:song, :artist_id, @artists, :id, :sort_name) %>
    

    The second parameter is the method to be assigned in the model being created/updated. So in your controller the value would be retrieved from the params hash with params[:song][:artist_id]

    A detailed explanation can be found in the Rails API docs under “collection_select”

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

Sidebar

Related Questions

Today is my first day using the Google Maps API. Now I have a
Today's my first day with Flex and FlashDevelop. In my ActionScript file, I have
Today is my first day using ASP.NET MVC, and I'm finding it very intriguing.
Please excuse me, today is my first day trying to setup a CI environment
Greetings. I am trying to learn Java and Swing (today is my first day).
First day at programming in Node today. I've been getting along nicely all day
I tried using PHPDoc for the first time today and quickly ran into a
I have been using pil for the first time today. And I wanted to
Today i have a little problem containing a File Upload. First some Infos: Rubyversion:
First let me state, today is my first day using NSesrviceBus - so I

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.