Rails presence method

I use Rails’ present? method constantly, but recently I stumbled across the presence method.

In the past, I have often found myself doing the following because params[:foo] could be nil or a blank string.

foo = params[:foo].present? ? params[:foo] : "something else"

I hate that i have to write params[:foo] twice. But the presence method is handy for this case. It returns nil if the item is nil or a blank string, but otherwise returns the value.

foo = params[:foo].presence || "something-else"