title: call a controller method from javascript ruby on rails
body: <p>I'm coding a scrabble application and I want to call an update method when the player drops a tile so I change the position in the database </p>
  
  <pre><code> function update_position(ev, posx, posy)
    {
  
      new Ajax.Request('/tiles_controller/update', {
      method: 'post',
      parameters: {
  posx: posx
  posy: posy}
                   });}`
  </code></pre>
  
  <p>and my controller looks like</p>
  
  <pre><code>  def update
      @tile = Tile.find(params[:id])
   @tile.update_attributes(params[:tile])
        end
      end
    end
  </code></pre>
  
  <p>I know the controller doesn't work I'm newbie coding in rails and I'm not sure how to pass the parameters from the javascript.</p>
  
  <p>Please help</p>