title: $.post to send something to database on click with ROR
body: <p>I have a 5 star rating jQuery widget on my page (that i created). It takes a function to handle its on click value. Previously this is what i had it do:</p>
  
  <pre><code>$('.fivestar').each(function() {
      $(this).ratings(5, $js_tile_data[$posValue][6]).bind('ratingchanged', function(event, data) {
          $.post('jRating/send_rating.php?whichpage='+$page+'&amp;id='+$js_tile_data[$posValue][0]+'&amp;rating='+data.rating);
          $(this).clickable(false);
      });
  });
  </code></pre>
  
  <p>Now i am using ruby on rails and want to achieve the same effect, storing the rating value to my database without loading a new page or anything. Also, if possible, i don't want to have to click a button or link or anything like that. Everything i have found trying to figure out how to do this requires a link or form or button. </p>
  
  <p>Any help or direction to where to look would be greatly appreciated. Thanks!</p>
  
  <p>Alright this is what i have in my function call:</p>
  
  <pre><code>$.post('/send_rating?whichpage=eat&amp;id='+$js_tile["id"]+'&amp;rating='+data.rating);
  </code></pre>
  
  <p>And then send_raing_controller.rb:</p>
  
  <pre><code>class SendRatingController &lt; ApplicationController
    def create
      @page = params[:whichPage]
      @id = params[:id]
      @rating = params[:rating]
  
      if (@page = "eat")
        @tile = EatTile.find(@id)
        @newVotes = @tile.num_votes + 1
        @newRating = (($tile.rating *@tile.num_votes) + @rating) / @newVotes
        @tile.num_votes = @newVotes
        @tile.rating = @newRating
      end
    end
  end
  </code></pre>
  
  <p>i used create because when i rake routes the post function goes to create. It isn't working properly, would it be because of the way i find the EatPage? Or is it not getting called correctly.</p>
  
  <p>Thanks</p>