Return empty on query RoR

I am doing a query for some data, if the query is empty or returns no data because there is none. How do I show that the query was empty?

Here I am finding Todo’s via params[:id]
@todo = Todo.find(params[:id])

Now if this comes back with some data it will list out what is in the database. But if it returns nothing how do I show this?
if @todo == nil
@todo = "Sorry No Todo's!"
end

I have tried an if statement (above) but it does not work... How do I show the following text? “Sorry No Todo’s” if there is nothing in the database?

Leave a Reply




Created by DesignForWeb company. All rights reserved © 2007-2010. Check also the iPhone / iPad developers blog
Disclaimer
The materials collected in this blog were taken from open access sources. We try our best to preserve the copyrights of original authors and clearly state the authorship as well as link to original source website where it's possible. Please leave your comment if you feel offended by any post or if you dispose of any information about breach of copyright law in this blog. We will do our best to resolve the situation immediately.