Hi all, Could anyone please help me with this query? I need to list user names and pictures of corresponding users and that too by limiting the list to just 5 users. this is the error that occurs in the controller: ArgumentError in User profilesController#mini_friendlist wrong number of arguments (2 for 1) RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/controllers/user_profiles_controller.rb:24:in `find'' #{RAILS_ROOT}/app/controllers/user_profiles_controller.rb:24:in `mini_friendlist'' Also "friendship" variable is in the view(mini_friendlist.rhtml): <% for friendship in @friends %> <img src="<%=image_path url_for( :controller => "user_pics", :action => "show_thumb", :id => friendship.user_pic ) %>" /><br /> <%= friendship.name %> <% end %> Heres the controller code: def mini_friendlist @friend = User.find(session[:user_id]) @user = User.find(params[:id]) @friends = @user.friends.find(:all, :limit => "5") end When I write this query I get a wrong argument error. Please guide me with this task... any help is appreciated. Cheers Cass -- 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 -~----------~----~----~----~------~----~------~--~---
Kumar.1524v-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-03 07:09 UTC
Re: Query Problem, limiting list results
in controller write like this @friend = User.find(params[:id]) @friends = User.find(:all, :conditions => ["LIKE ?", <what u want to find>]) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rein.henrichs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Sep-03 07:33 UTC
Re: Query Problem, limiting list results
Kumar: Not sure how this helps with limiting the results. "WHERE LIKE ..." isn''t valid SQL either. Cass: Stack trace shows line 24 to be the problem. The controller code you posted is syntactically valid ruby/rails (except that you should just do :limit => 5 rather than "5") so it''s hard to tell why you''re getting that error. Which line is line 24? On Sep 3, 2:09 am, "Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> in controller write like this > > @friend = User.find(params[:id]) > @friends = User.find(:all, :conditions => ["LIKE ?", <what u want > to find>])--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
unknown wrote:> Kumar: Not sure how this helps with limiting the results. "WHERE > LIKE ..." isn''t valid SQL either. > > Cass: Stack trace shows line 24 to be the problem. The controller code > you posted is syntactically valid ruby/rails (except that you should > just do :limit => 5 rather than "5") so it''s hard to tell why you''re > getting that error. Which line is line 24? > > On Sep 3, 2:09 am, "Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>Hi Kumar, Thanks for the reply, I tried :limit => 5 too but it still returns the same error. Just not able to figure out why this is occurring... Cheers Cass -- 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 -~----------~----~----~----~------~----~------~--~---
Cass Amino wrote:> unknown wrote: >> Kumar: Not sure how this helps with limiting the results. "WHERE >> LIKE ..." isn''t valid SQL either. >> >> Cass: Stack trace shows line 24 to be the problem. The controller code >> you posted is syntactically valid ruby/rails (except that you should >> just do :limit => 5 rather than "5") so it''s hard to tell why you''re >> getting that error. Which line is line 24? >> >> On Sep 3, 2:09 am, "Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > Hi Kumar, > > Thanks for the reply, I tried :limit => 5 too but it still returns the > same error. Just not able to figure out why this is occurring... > > Cheers > > CassBy the way, Line #24 is @friends = @user.friends.find(:all, :limit => "5") Cheers Cass -- 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 -~----------~----~----~----~------~----~------~--~---
Do you have your has_many :friends in the User model? My thought is that you may be mistakenly calling Enumerable#find (which takes 1 argument) rather than AR::Base#find (which takes 2). The rest of the stack trace should show you whether or not AR::Base#find is being called. On Sep 3, 2:46 am, Cass Amino <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Cass Amino wrote: > > unknown wrote: > >> Kumar: Not sure how this helps with limiting the results. "WHERE > >> LIKE ..." isn''t valid SQL either. > > >> Cass: Stack trace shows line 24 to be the problem. The controller code > >> you posted is syntactically valid ruby/rails (except that you should > >> just do :limit => 5 rather than "5") so it''s hard to tell why you''re > >> getting that error. Which line is line 24? > > >> On Sep 3, 2:09 am, "Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <Kumar.15...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > Hi Kumar, > > > Thanks for the reply, I tried :limit => 5 too but it still returns the > > same error. Just not able to figure out why this is occurring... > > > Cheers > > > Cass > > By the way, Line #24 is > > @friends = @user.friends.find(:all, > :limit => "5") > > Cheers Cass > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Rein Henrichs wrote:> Do you have your has_many :friends in the User model? My thought is > that you may be mistakenly calling Enumerable#find (which takes 1 > argument) rather than AR::Base#find (which takes 2). > > The rest of the stack trace should show you whether or not > AR::Base#find is being called. > > On Sep 3, 2:46 am, Cass Amino <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi Rein, Thanks for your reply, am using has_many_friendships plugin, may be this is the reason? Could you please let me know how to tackle this issue? Cheers Cass -- 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 -~----------~----~----~----~------~----~------~--~---
Cass Amino wrote:> Rein Henrichs wrote: >> Do you have your has_many :friends in the User model? My thought is >> that you may be mistakenly calling Enumerable#find (which takes 1 >> argument) rather than AR::Base#find (which takes 2). >> >> The rest of the stack trace should show you whether or not >> AR::Base#find is being called. >> >> On Sep 3, 2:46 am, Cass Amino <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Hi Rein, > > Thanks for your reply, am using has_many_friendships plugin, may be > this is the reason? Could you please let me know how to tackle this > issue? > > Cheers > > CassHi Rein, Yes I do have has_many_friends in my user model Cass -- 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 -~----------~----~----~----~------~----~------~--~---