From: Stefan Mahlitz Date: 2007-02-25T09:08:48+09:00 Subject: Re: Testing a query result Phrogz wrote: > On Feb 24, 11:28 am, Mahmou M'hiri wrote: >> It's a very basic question, i want just to test if this query did return >> any result. >> >> @BookDetails = Book.find(params[:id]) > > You will probably get better results asking this question on the Ruby > on Rails discussion forum. You have instead asked it on the ruby-talk > mailing list. I actually think that this is an ActiveRecord question. Does this qualify for a redirect to rails (even if params[:id] is a good hint)? I have to admit that I do not know whether rails does change this behaviour. Do we cover ActiveRecord questions on ruby-talk? To answer the original question: ActiveRecord will raise an ActiveRecord::RecordNotFound exception which you can detect/catch via begin @BookDetails = Book.find(params[:id]) rescue ActiveRecord::RecordNotFound # the query did not return a result end Stefan