0

while running the below mysql query in ruby on rails

cnt=Domainurl.find_by_sql["SELECT MAX(`count`) FROM domainurls WHERE `domaindetail_id` = ?", @domain.id]
puts cnt.count

I am getting below error:

"error is: wrong number of arguments (0 for 1)"

Can anybody tell where exactly am I wrong?

1 Answer 1

4

You either need to wrap the argument in parenthesis or add a space.

cnt=Domainurl.find_by_sql(["SELECT MAX(`count`) FROM domainurls WHERE `domaindetail_id` = ?", @domain.id])

or

cnt=Domainurl.find_by_sql ["SELECT MAX(`count`) FROM domainurls WHERE `domaindetail_id` = ?", @domain.id]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.