title: Why is AJAX in Rails 3 so hard? Or, what am I doing wrong?
body: <p>None of the tutorials I seem do what I'm trying to do.  Very simply, I want a user to be able to submit a POST request to a controller (to "LIKE" a video) and have the controller respond back with a JSON object.  Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong> Because SO is messing the formatting up, here is a gist of my code too:
      <a href="https://gist.github.com/813503" rel="nofollow">https://gist.github.com/813503</a></p>
  
  <h2>Here is my controller:</h2>
  
  <pre><code>class LikesController &lt; ApplicationController
  
    before_filter :get_ids
  
    respond_to :json, :js
  
    def videolink
      results = {}
  
      # check to see if the user has liked this videolink before
      if current_user
        liked = Like.video?(current_user, @vid_id)
  
        results["status"] = "OK"      
        results["liked"] = liked
      else
        results["status"] = "Error"
        results["message"] = "User not logged in"
      end
  
      respond_with( results.to_json ) 
    end
  
  
    def update
      results = {}
  
      if current_user
        results["status"] = "OK"  
      else
        results["status"] = "Error"
        results["message"] = "User not logged in"
      end
  
      respond_with( results.to_json )
    end
  
  
    private
  
    def get_ids
      @vid_id = params[:videolink_id]
    end
  
  end
  </code></pre>
  
  <h2>Here is my JS file:</h2>
  
  <pre><code>$("#likeVideo").click(function() {
      $.ajax({
          contentType: "application/json",
          data: { game_id: game_id,   videolink_id: current_video["videolink"]["id"] },
          dataType: "json",
          type: "POST",
          url: "/likes/" + game_id,
          success: function(data) {
              console.log("Success", data);
          }
      });     
  
      return false;
  });
  </code></pre>
  
  <h2>My routes:</h2>
  
  <pre><code>  resources :likes do
      collection do
        get "videolink"
      end
  
      member do
        post :update
      end
    end
  </code></pre>
  
  <h2>And here is the error I get:</h2>
  
  <p><code></p>
  
  <h1>
    NoMethodError
      in LikesController#update
  </h1>
  
  <p>undefined method `{&quot;status&quot;:&quot;OK&quot;}_url' for #&lt;LikesController:0x0000010178be58&gt;
  </code></p>