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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:58:49+00:00 2026-05-16T20:58:49+00:00

I am working on a Rails 3 app, and I need to return back

  • 0

I am working on a Rails 3 app, and I need to return back a list of players where the sum of points_received per player, is greater than a specified amount.

I have tried this:

Answer.sum(:points_received, :group => 'player_id').having("points_received > 5")

but of course this gives me an error: NoMethodError: undefined method `having’ for #

Answer model is defined as:

 create_table "answers", :force => true do |t|
    t.integer  "player_id"
    t.integer  "round_id"
    t.string   "response"
    t.integer  "points_received"
  end

So I understand that sum is returning back an ordered hash of player_id, sum(points_received), but I only want to see the results where the sum(points_received) is greater than a specified value.

Any suggestions?

Thanks 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-05-16T20:58:50+00:00Added an answer on May 16, 2026 at 8:58 pm

    Can you believe it, just after I posted this, I then had a thought on swapping some syntax around and got the result. This is what I ended up doing:

    Answer.group(:player_id).having("sum(points_received) > 5").sum(:points_received)
    

    this returned me back the hash of player_ids and sum(points_received) for only the ones where the sum is greater than 5.

    Thanks for reading anyway. Maybe this will help someone one day!

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

Sidebar

Related Questions

I'm in an app that is on Rails 2.3.8, and need to return an
I'm working on a Rails app and am looking to include some functionality from
I'm working on a rails app that has a whole bunch of before filters
I'm working on a Rails app that sends data through a form. I want
So I'm working on a Rails app to get the feeling for the whole
I am working on the admin section of a new rails app and i'm
I'm working on an analytics page for a rails app. The analytics page does
I'm kinda new to using Rails, and an app I am working on is
I'm working on a rails app that integrates with other systems (which can't be
I've been working on a rails app for a couple of days now that

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.