wrong number of arguments (2 for 0..1)

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.

Try this:

https://gist.github.com/1133491

Kurtis Rainbolt-greene wrote in post #1015633:

Try this:

gist:1133491 · GitHub

wrong number of arguments (2 for 0..1) 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

thankyou 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

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)

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