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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:34:44+00:00 2026-05-17T16:34:44+00:00

I have this data and as you can see I have about 10 requests.

  • 0

I have this data and as you can see I have about 10 requests. A request has a venue, song, date and artist. I need to loop those requests and if there is are two request with the same song made to the same venue and date then i need to add then to a checkbox. For example:

#<Request id: 8, artist: "Metallica", song: "Turn the Page", venue: 
"Rod Laver Arena at Melbourne Park - Melbourne Vic", showdate: "2010-10-09", 
amount: nil, user_id: 6, created_at: "2010-10-09 01:32:26", 
updated_at: "2010-04-09 01:32:26", like_reason: "Its a good song", pledge: 100>,

#<Request id: 9, artist: "Metallica", song: "Turn the Page", venue: 
"Rod Laver Arena at Melbourne Park - Melbourne Vic", showdate: "2010-10-09", 
amount: nil, user_id: 6, created_at: "2010-10-09 01:32:26", 
updated_at: "2010-05-09 01:32:26", like_reason: "Its great", pledge: nil>,

#<Request id: 10, artist: "Metallica", song: "Enter Sandman", venue: 
"Aector Arena - Auckland Central, New Zealand", showdate: "2010-10-11", 
amount: nil, user_id: 6, created_at: "2010-10-09 01:32:26", 
updated_at: "2010-05-09 01:32:26", like_reason: "good tune", pledge: nil>,

As you can see i have two request to the same venue and the same date and the same song. I want a loop that will create checkboxes in the view but if it encounters the same song with the same date info then add the id in the checkbox array..like this

<input value="Turn the Page"  name="song[8, 9]" type="checkbox">

other wise i would only have one in the array for that checkbox is that is the only one

<input value="Enter Sandman"  name="song[10]" type="checkbox">

@past_requests is the array that will contain all the requests…
Any ideas on how to achieve this

  • 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-17T16:34:44+00:00Added an answer on May 17, 2026 at 4:34 pm

    If you can come up with a group_by function that groups by the combination of venue, date and song then that would simplify the problem.

    e.g. as a simple example we could use a concatenated string as a the key:

    grouped_requests = requests.group_by do |req|
      "#{req.artist}/#{req.song}/#{req.venue}/#{req.date}"
    end
    

    Then your checkboxes could be generated with:

    <% grouped_requests.values.each do |requests| %>
      <% request_ids = requests.collect { |request| request.id } %>
      <%= check_box_tag requests.first.song, "song[#{request_ids.join(',')}]" %>
    <% end %>
    

    Notice that we don’t care which request we use for the song name because all the requests in a grouping have the same song so we can just use requests.first.song

    Alternatively, you could look at extracting venue/date/song into a Performance model and then linking requests to performances. That might simplify things.

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

Sidebar

Related Questions

I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I have this code to update users data, but I can't write the for
I have a stored procedure that logs some data, how can I call this
I have this php code. As you can see i query a mysql database
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this data: /blabla/blabla (abs,def) /yxz I use this regex (.*)(?:\(([^$]*)\))?\n But it
I have this data: 1, 0., 0., 1500. . . 21, 0., 2000., 1500.
I have this data in a table, for instance, id name parent parent_id 1
Let say if I have this data my_data = [ 10 20 30 40;
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =

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.