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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
@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. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > > -- > 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/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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/-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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/ > > > -- > 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/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---