Last Updated: February 25, 2016
·
1.361K
· zegomesjf

activesupport presence

object.presence</code> is equivalent to object.present? ? object : nil</code>

Use
region = params[:state].presence || params[:country].presence || 'US' </code>

instead

state   = params[:state]   if params[:state].present?
country = params[:country] if params[:country].present?
region  = state || country || 'US'</code></pre>