Wrong number of arguments (0 for 1) error.... Help!

I have no clue. Author.find_by_name should be working when it
(apparently) is not. Something is broken.

Ryan B.
Freelancer

Ryan B. wrote:

I have no clue. Author.find_by_name should be working when it
(apparently) is not. Something is broken.

Ryan B.
Freelancer
http://frozenplague.net

I think so too. Thanks for your help.
Why is it so hard to find the correct syntax for doing a subselect in
Rails?
Is subselect not supported in Rails?

Cypray

And finally, what version of Rails?

Ryan B.
Freelancer

It’s supported. It’s the syntax I showed you before:

Author.find_by_name(“Blah”).books, will get you all the books by that
author.

Ryan B.
Freelancer

On Dec 10, 5:36 am, Jay M. [email protected] wrote:

Rails?
Is subselect not supported in Rails?

For the sake of argument you can do

@books = Books.find_by_sql [“SELECT * FROM books WHERE title IN
(SELECT
title FROM authors WHERE name = ?)”, params[:author][:name]]

But really whenever you use find_by_sql you should give yourself a
long hard look in the mirror. There’s almost always a better way.

Fred

Frederick C. wrote:

On Dec 10, 5:36�am, Jay M. [email protected] wrote:

Rails?
Is subselect not supported in Rails?

For the sake of argument you can do

@books = Books.find_by_sql [“SELECT * FROM books WHERE title IN
(SELECT
title FROM authors WHERE name = ?)”, params[:author][:name]]

But really whenever you use find_by_sql you should give yourself a
long hard look in the mirror. There’s almost always a better way.

Fred

Thanks a lot Fred. It works perfect now. Thanks for your help guys.

Cypray