Topic: ERRor: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.

Re: ERRor:wrong number of arguments (2 for 0..1)

try this:

@animals=Bird.find(:all,:conditions =>['state like ?', "%#{params[:number]}%"])

Last edited by BradHodges (2011-08-08 12:59:48)

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: ERRor:wrong number of arguments (2 for 0..1)

Hello BradHodges,
Thanks for your reply.first statement is working.problem is with the second statement.please can u tell are there any other methods which does this job?

Re: ERRor:wrong number of arguments (2 for 0..1)

I think what's happening is that @animals is an Array of Bird records,  you're treating it like it's a model that you can find on, it isn't

Maybe what you want is:

@animals=Bird.find(:all,:conditions =>['state like ?', "%#{params[:number]}%"])
@animals.each do |ani|
  if ani.city == 'bad'
    puts "bad city in state #{ani.state}"
  end
end

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.