Hi, please can anyone help me with this code....when i am executing the following code, i am getting the error. code: @animals=Bird.find(:all,:conditions =>[''state like?'', ''%'' + params[:number]+''%'']) @ani=@animals.find(:all,:conditions =>[''city like?'', ''%bad%'']) error: wrong number of arguments (2 for 0..1) please can anyone help me out. Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try this: https://gist.github.com/1133491 On Mon, Aug 8, 2011 at 10:36 PM, praveen k. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > please can anyone help me with this code....when i am executing the > following code, i am getting the error. > > code: > @animals=Bird.find(:all,:conditions =>[''state like?'', ''%'' + > params[:number]+''%'']) > @ani=-xkKXtlJnL0hIGN9crfQanw@public.gmane.org(:all,:conditions =>[''city like?'', ''%bad%'']) > > error: > wrong number of arguments (2 for 0..1) > > please can anyone help me out. > Thanks. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Kurtis Rainbolt-Greene: - Hacker, Designer, Author - 3725 Onyx Street, Eugene, OR 97405 - (202) 643-2263 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kurtis Rainbolt-greene wrote in post #1015633:> Try this: > > https://gist.github.com/1133491 > > > On Mon, Aug 8, 2011 at 10:36 PM, praveen k. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> wrong number of arguments (2 for 0..1) >> To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > > -- > Kurtis Rainbolt-Greene: > - Hacker, Designer, Author > - 3725 Onyx Street, Eugene, OR 97405 > - (202) 643-2263thankyou Kurtis Rainbolt-Greene. ya i tried it but even it is giving me an error. error: undefined method `condition'' for Bird(id: integer, state: string, city: string):Class Thankyou -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 August 2011 06:36, praveen k. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > please can anyone help me with this code....when i am executing the > following code, i am getting the error. > > code: > @animals=Bird.find(:all,:conditions =>[''state like?'', ''%'' + > params[:number]+''%'']) > @ani=-xkKXtlJnL0hIGN9crfQanw@public.gmane.org(:all,:conditions =>[''city like?'', ''%bad%'']) > > error: > wrong number of arguments (2 for 0..1)Is it as simple as the fact that you have not got a space before the ?, so that rails does not recognise it as a value to be filled in? Otherwise which line is generating the error? Note that if you use the rails console you can type statements directly into the console to see whether they work which can help to diagnose which bit of a statement is giving problems. params will not be available of course but you can try it with fixed text to check it works. However you do it a useful approach is to simplify the failing statement right down to something that works, then build it up to what you really want and then you will find the detail that is causing the problem. As I said you can do most of this in the rails console. Colin Colin> > please can anyone help me out. > Thanks. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.