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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:30:32+00:00 2026-05-24T11:30:32+00:00

I wish to use this method like @results = Candidate.all.match_against(options) , where options is

  • 0

I wish to use this method like

@results = Candidate.all.match_against(options)

, where “options” is an array of integers. And it should return me all candidates with their match score.

In Candidate model I have a method for matching candidates against options given as a parameter.

def self.match_against(cu_options)                                           
  select("candidates.id, candidates.first_name, candidates.last_name, candidates.number, 
  sum(case when c_answers.option_id in (?) then 1 else 0 end) as score", cu_options)
  .joins("join answers as c_answers on c_answers.user_id = candidates.user_id")
  .joins("join options on c_answers.option_id = options.id")
  .where("options.ordering >= 0")
  .group("candidates.id, candidates.number, candidates.first_name, candidates.last_name")
end

For some reason when I’m calling this method it gives me an error

ArgumentError: wrong number of arguments (2 for 1)
from /home/mika/.rvm/gems/ruby-1.9.2-p180@vaalikone/gems/activerecord-3.0.7/lib/active_record/relation/query_methods.rb:34:in `select'
from /home/mika/.rvm/gems/ruby-1.9.2-p180@vaalikone/gems/activerecord-3.0.7/lib/acteve_record/base.rb:442:in `select'
from /home/mika/projects/vaalikone/app/models/candidate.rb:35:in `match_against'
...

I have no idea where the second argument is coming from. I’m passing in only one argument. I’m using postgresql.

  • 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-24T11:30:33+00:00Added an answer on May 24, 2026 at 11:30 am

    Actually, you are passing two arguments to the select scope:

    • the string “candidates.id, candidates.first_name, candidates.last_name, candidates.number,
      sum(case when c_answers.option_id in (?) then 1 else 0 end) as score”
    • the variable cu_options

    Is there any reason for that?

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

Sidebar

Related Questions

I wish to use the method with the following signature: exec(String command, String[] envp,
Until now, I've used a method with log4j like this: void writeMethod(String msg){ StackTraceElement[]
I want to use an interface like this : public interface ResultItem { public
I wish to use Spring MVC to provide a REST web service. However, running
I wish to use a COM dll in my C++ library. The way I
I wish to use the Translator classes of Zend framework in my app, but
I wish to use common CRC logic in a VB.NET or C# application as
I wish to use JSON.Net on a brand spankin new Mono class library (say
I wish to use a jQuery .load(oracle apex url) query. I have a main
I wish to use sp_start_job to start a job from within an insert trigger

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.