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>
Written by José Gomes Júnior
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#