title: Avoiding nil in Rails views
body: <p>I'm sure this has been asked already, but I can't find the answer.</p>
  
  <p>I have a Project model, which has a <code>belongs_to</code> relationship with my Client model. A client has a name, but a project doesn't necessarily have a client.</p>
  
  <p>In my view, I've got code like this:</p>
  
  <pre><code>&lt;%=h project.client &amp;&amp; project.client.name %&gt;
  </code></pre>
  
  <p>because if the project doesn't have a client then trying to access <code>project.client.name</code> causes a NoMethodError (<code>nil</code> doesn't have a method called <code>name</code>).</p>
  
  <p>The question is, is it acceptable to have this kind of nil checking in the view, or should I be looking for another way around it?</p>