title: Rails controller action without a view
body: <p>I just want to do a rails action without a view.  </p>
  
  <p>In my <strong>'routes.rb'</strong>  </p>
  
  <pre><code>resources :pictures do
      member do 
          post 'dislike'  
      end  
  end
  </code></pre>
  
  <p>In my <strong>'PictureController.rb'</strong><br>
  this does not work</p>
  
  <pre><code>def dislike
      @picture = Picture.find(params[:id])
      @like = Like.find(:user_id =&gt; current_user.id, :picture_id =&gt; params[:id])
  
      @like.destroy
  
      respond_to do |format|
          format.html { render :action =&gt; :show, :id =&gt; params[:id], notice: 'You don\'t  like this picture anymore.' }
          format.json { render json: @picture }
      end
  end
  </code></pre>
  
  <p>neither do this</p>
  
  <pre><code>def dislike
      @picture = Picture.find(params[:id])
      @like = Like.find(:user_id =&gt; current_user.id, :picture_id =&gt; params[:id])
  
      @like.destroy
  
      respond_to do |format|
          format.html { redirect_to @picture, notice: 'You don\'t  like this picture anymore.' }
          format.json { render json: @picture }
      end
  end
  </code></pre>
  
  <p>or even this (but this is not the case for me, i want a feedback to the user via json and via html)</p>
  
  <pre><code>def dislike
      @picture = Picture.find(params[:id])
      @like = Like.find(:user_id =&gt; current_user.id, :picture_id =&gt; params[:id])
  
      @like.destroy
  
      render :nothing =&gt; true
  end
  </code></pre>
  
  <p>But i keep getting this error message:  </p>
  
  <pre><code>ActionView::MissingTemplate: Missing template pictures/dislike, application/like with {:locale=&gt;[:en], :formats=&gt;[:html], :handlers=&gt;[:erb, :builder, :coffee]}.
  </code></pre>
  
  <p>How should i tell rails that this action in PicturesController does not needs a view?</p>
  
  <h1>Solved!</h1>
  
  <p>I didn't really solved the problem of telling rails i did not need a view, i just created another controller, put the method in it, and told rails routing to match the dislike action with a <code>match</code> call.
  I cannot tell for sure, but i think it was a problem with the <code>resources :picture</code> in my <code>routes.rb</code> file...</p>
  
  <p>But anyway, thank you guys!
  =)</p>