title: Render different action for ajax vs html request in rails 3
body: <p>In rails three I have the following code for my destroy action in a photos controller</p>
  
  <pre><code> def destroy
        @photo = Photo.find(params[:id])
       if @photo.destroy
         flash[:notice] = t('photo.deleted')
         respond_to do |format|
           if request.xhr?
             format.js
           else
             format.html {redirect_to photos_path}
           end
         end
       else
         flash[:alert] = t('.photo.error_deleting')
         if request.xhr?
           redirect_to(photos_url)
         else
           redirect_to(photo_path @photo)
         end
       end
     end
  </code></pre>
  
  <p>The goal is essentially to redirect to the index page if this is called from a standard link and render destroy.js if called from a remote link.
  This works but I was wondering if there is a cleaner way of doing this in rails 3.  Possibly using the respond_with operator?</p>
  
  <p>Thanks</p>