Forum: Ruby on Rails Can anyone see what is wrong with this code?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
RJ (Guest)
on 2007-03-23 17:17
Using find by sql to get some results. The error is:

wrong number of arguments (0 for 1)
#{RAILS_ROOT}/app/models/result.rb:24:in `find_by_sql'

def self.get_tests_run(project)
    @project = Project.find(project)
    @builds = []
    @results = []
    @project.testsuite.each do |testsuite| do | build|
       @builds <<
    now =
    count = 7
    7.times do
    @results << Result.find_by_sql["SELECT count(distinct(tcid)) FROM
results WHERE build_id in (?) and daterun <= ?", @builds,,now.month, - count) ]
      count -= 1

I cannot see what is wrong with that find_by_sql statement.


Steve R. (Guest)
on 2007-03-23 18:24
(Received via mailing list)
Missing parentheses around the argument. You have square brackets for
the SQL
parameter substitution but no () for the argument list.

Neha C. wrote:
>     @results = []
>,now.month, - count) ]
> --
> Posted via
> >

View this message in context:
Sent from the RubyOnRails Users mailing list archive at
This topic is locked and can not be replied to.