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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:29:10+00:00 2026-06-07T13:29:10+00:00

In my app: A song has many setlists through allocations A setlist has many

  • 0

In my app:

A song has many setlists through allocations
A setlist has many songs through allocations
allocations belong to setlists and songs

I’m trying to add a song from the existing library to a set list using the following form:

 <% @songs.each do |song| %>
            <tr>
               <%= nested_form_for(@setlist.allocations.build(song_id: song.id)) do |f| %>
               <td><%= song.title %></td>
               <td><%= song.artist %></td>
               <td><%= song.key %></td>
               <td>
                     <div><%= f.hidden_field :song_id %></div>
                  <%= f.submit "ADD", class: "btn btn-small btn-primary" %>
                  <% end %>

               </td>
            </tr>
          <% end %>

In my setlists controller I have:

def edit
    @songs = Song.all(order: 'title')
    @setlist = Setlist.find(params[:id])
    @setSongs = @setlist.songs
    @allocations = Allocation.where("setlist_id =?", @setlist) 
  end

  def update
    @setlist = Setlist.find(params[:id])
    song = Song.find(params[:song_id])
    @setlist.allocate!(song)
    if @setlist.update_attributes(params[:setlist])
      # Handle a successful update.
      flash[:success] = "SAVED!"
      redirect_to setlists_path
    else
      render 'edit'
    end
  end

The allocate method is specified in the setlist model as:

 def allocate!(song)
    allocations.create!(song_id: song.id)
  end

At the moment it returns the following whenever I click to add songs to the setlist.

NoMethodError in SetlistsController#update
undefined method `id’ for :song:Symbol

The bug is also wierd in that it only does the error above for the first record in the table, whilst all the others render the “error” page for when a record hasn’t been added.

Any pointers would be appreciated. Thanks very much in advance

  • 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-07T13:29:12+00:00Added an answer on June 7, 2026 at 1:29 pm

    You are passing the Symbol :song to allocate! in

    @setlist.allocate!(:song)
    

    when allocate! is expecting an instance of Song to be passed. The :song symbol has no method .id, hence the error.

    If you’re trying to pass the Song related to

    <%= f.hidden_field :song_id %>
    

    you must first get the Song.

    song = Song.find(params[:allocation][:song_id])
    @setlist.allocate!(song)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple mediaplayer app that downloads a song from a predetermined URL
Is there any way to send a song title to the spotify app from
I am trying to make an app that plays MP3 songs. My program flow
I'm grabbing song data from the iOS music library (as an NSData object), but
I need to get an info about the app/song/video by item id from iTunes
I'm using Backbonejs for my app and I'm trying to add Facebook comments and
In my app i have a music player which actually the song from iTunes
In my app I am using OpenAl to trim the audio song, now how
I'm developing an App in which i have to record a song and a
In My app i am using openAl to cut the portion of audio song

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.