title: Check if not nil and not empty in Rails shortcut?
body: <p>I have a show page for my Users and each attribute should only be visible on that page, if it is not nil and not an empty string. Below I have my controller and it is quite annoying having to write the same line of code <code>@user.city != nil &amp;&amp; @user.city != ""</code> for every variable. I am not too familiar with creating my own methods, but can I somehow create a shortcut to do something like this: <code>@city = check_attr(@user.city)</code>? Or is there a better way to shorten this procedure?</p>
  
  <p><strong>users_controller.rb</strong></p>
  
  <pre><code>def show 
    @city = @user.city != nil &amp;&amp; @user.city != ""
    @state = @user.state != nil &amp;&amp; @user.state != ""
    @bio = @user.bio != nil &amp;&amp; @user.bio != ""
    @contact = @user.contact != nil &amp;&amp; @user.contact != ""
    @twitter = @user.twitter != nil &amp;&amp; @user.twitter != ""
    @mail = @user.mail != nil &amp;&amp; @user.mail != ""
  end
  </code></pre>