title: What is the best way to check if an attribute exists and is set?
body: <p>I have a common view that lists two different models. The only difference is that when setting the <code>link_to</code> action, one of the models has a <code>link</code> attribute and the other doesn't. I want to check if the <code>link</code> attribute exists, and if it does, check if it's set. I have the following which works, but I was wondering if there was a better way.</p>
  
  <pre><code>%li
    - if @element.has_attribute?("link") &amp;&amp; @element.link
      = link_to @element.title, @element.link
    - else
      = link_to @element.title, @element
  </code></pre>