title: Rails Helper for user picture
body: <p>I currently have some dirty code in a partial and thought it'd be good to move it to a Helper but can't make it happen.</p>
  
  <p>Here is what I have in my "user_picture" partial so far:</p>
  
  <pre><code>&lt;% if defined?(user) %&gt;
      &lt;%- if user.picture_id == 0 -%&gt; 
          &lt;%= image_tag('/images/einstein.png', :size =&gt; size) -%&gt;
      &lt;%- else -%&gt;
          &lt;%= image_tag(user.picture.public_filename(:avatar), :size =&gt; size) %&gt;
      &lt;%- end -%&gt;
  &lt;% else %&gt;
      &lt;%- if !logged_in_user || logged_in_user.picture_id == 0 -%&gt; 
          &lt;%= image_tag('/images/einstein.png', :size =&gt; size) -%&gt;
      &lt;%- else -%&gt;
          &lt;%= image_tag(logged_in_user.picture.public_filename(:avatar), :size =&gt; size) %&gt;
      &lt;%- end -%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>How do I make it a helper?</p>
  
  <p>Thanks!</p>