Hi everyone,
I’m doing a find_by_sql to do a paginated list of a users’ friends’
recipes, but I keep getting an error with my find_by_sql line (Wrong
number of arguments 0 for 1). Is there anything I’m obviously doing
wrong?
query = "select r.*
from recipes r, friends_users f
where r.user_id = f.friend_id and f.user_id = ?
order by r.date_added desc
limit #{offset}, #{per_page}"
@friends_recipes = Recipe.find_by_sql[query, params[:id]]
Let me know if it’s something simple I’ve missed. I can’t figure it
out!
Thanks a lot,
Dave
@friends_recipes = Recipe.find_by_sql[query, params[:id]]
should be…
@friends_recipes = Recipe.find_by_sql(query, params[:id])
I believe…
–Jeremy
On 1/20/07, Dave A. [email protected] wrote:
where r.user_id = f.friend_id and f.user_id = ?
Dave
–
Posted via http://www.ruby-forum.com/.
–
My free Ruby e-book:
http://www.humblelittlerubybook.com/book/
My blogs:
http://www.rubyinpractice.com/
I tried that as well, and I get an error (Arguments 2 for 1). I can’t
seem to figure out how to give it the right number of arguments, even
though it looks right to me! Frustrating… 
Dave
Jeremy McAnally wrote:
@friends_recipes = Recipe.find_by_sql[query, params[:id]]
should be…
@friends_recipes = Recipe.find_by_sql(query, params[:id])
I believe…
–Jeremy
On 1/20/07, Dave A. [email protected] wrote:
where r.user_id = f.friend_id and f.user_id = ?
Dave
–
Posted via http://www.ruby-forum.com/.
–
My free Ruby e-book:
http://www.humblelittlerubybook.com/book/
My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/
Thank you, it works perfectly!
Jeremy McAnally wrote:
Oh smack
@friends_recipes = Recipe.find_by_sql([query, params[:id]])
That should work I thnk. It’s too late to think. 
–Jeremy
On 1/20/07, Dave A. [email protected] wrote:
Oh smack
@friends_recipes = Recipe.find_by_sql([query, params[:id]])
That should work I thnk. It’s too late to think. 
–Jeremy
On 1/20/07, Dave A. [email protected] wrote:
Dave
http://www.humblelittlerubybook.com/book/
–
My free Ruby e-book:
http://www.humblelittlerubybook.com/book/
My blogs:
http://www.rubyinpractice.com/