title: How to check user in custom / index action with devise?
body: <p>I'm trying to check a couple of rules in my <code>photos#latest</code> view, but I don't know how to define User in my <strong>Photos Controller</strong>. </p>
  
  <p>I want to check:</p>
  
  <pre><code>&lt;% if current_user == @photo.user or current_user.has_role? :admin %&gt;
   &lt;%= link_to "Editar Spot", edit_user_photo_path(@user, @photo), class: "edit" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>def latest
      @user = current_user
      @categories = Category.all(:order =&gt; 'name')
      @zones = Zone.all(:order =&gt; 'name')
      @photos = Photo.latest_photos.quality.paginate(:page =&gt; params[:page])
      @action = 'general'
      render :index
  end
  </code></pre>
  
  <p>That will say:</p>
  
  <p><strong>undefined method `user' for nil:NilClass</strong></p>
  
  <p>How should I define User in my controller when I don't have an ID or params?</p>
  
  <p>Thanks</p>