testing for non-existent parameters with "if"

Rails gives me an error when I test for a blank param like this:

        if params[:post][:id]

If I have params[:post][:id], things are fine. But if I have params[:event][:id] instead, I get this error:

And a third solution yet     if defined? params[:post][:id]     else     end

It will not always work if you use it from a view (because of how local variables are handled), but for Models, Controllers and the sort it should be fine.

regards, javier ramirez