title: Ruby on rails - PUT method on update ajax
body: <p>Could someone tell me why this PUT method doesn't work please.</p>
  
  <pre><code>$.ajax({
          type: "PUT",
          dataType: "script",
          url: '/resources/35',
          data:
          {
              resource : { pos_y: 45, pos_x: 50 }
          }
      }).done(function( msg )
              {
                  alert( "Data Saved: " + msg );
              });
  </code></pre>
  
  <p>Server says that I have used the <strong>GET method</strong> but in my ajax request I have <strong>type: "PUT"</strong></p>
  
  <pre><code>Started GET "/resources/35?resource%5Bpos_y%5D=45&amp;resource%5Bpos_x%5D=50&amp;_=1344001820350" for 192.168.1.89 at 2012-08-03 15:50:20 +0200
  Processing by ResourcesController#show as */*
    Parameters: {"resource"=&gt;{"pos_y"=&gt;"45", "pos_x"=&gt;"50"}, "_"=&gt;"1344001820350", "id"=&gt;"35"}
    User Load (0.3ms)  SELECT "users".* FROM "users" 
    Resource Load (0.1ms)  SELECT "resources".* FROM "resources" WHERE "resources"."id" = ? LIMIT 1  [["id", "35"]]
    Rendered resources/show.html.erb within layouts/login (2.3ms)
  Completed 200 OK in 238ms (Views: 235.9ms | ActiveRecord: 0.4ms)
  </code></pre>
  
  <p>resources_controller.rb</p>
  
  <pre><code> # PUT /resources/1                                                                                                                                                             
    # PUT /resources/1.json                                                                                                                                                        
    def update
      @resource = Resource.find(params[:id])
  
      respond_to do |format|
        if @resource.update_attributes(params[:resource])
          format.html { redirect_to @resource, notice: 'successfully updated.' }
          format.js
        else
          format.html { render action: "edit" }
          format.js
        end
      end
    end
  </code></pre>
  
  <p>I have tried adding <strong>_method: 'put'</strong> But it's still the same</p>
  
  <pre><code>$.ajax({
          type: "PUT",
          dataType: "script",
          url: '/resources/35',
          data:
          {
              resource : { pos_y: 45, pos_x: 50 },
              _method: 'put'
          }
      }).done(function( msg )
              {
                  alert( "Data Saved: " + msg );
              });
  </code></pre>
  
  <p>Server: </p>
  
  <p>"resource%5Bpos_y%5D=45&amp;resource%5Bpos_x%5D=50&amp;<strong><em>method=put</strong>&amp;</em>=1344004390840"</p>
  
  <pre><code>Started GET "/resources/35?resource%5Bpos_y%5D=45&amp;resource%5Bpos_x%5D=50&amp;_method=put&amp;_=1344004390840" for 192.168.1.89 at 2012-08-03 16:33:10 +0200
  Processing by ResourcesController#show as */*
    Parameters: {"resource"=&gt;{"pos_y"=&gt;"45", "pos_x"=&gt;"50"}, "_"=&gt;"1344004390840", "id"=&gt;"35"}
    User Load (0.3ms)  SELECT "users".* FROM "users" 
    Resource Load (0.1ms)  SELECT "resources".* FROM "resources" WHERE "resources"."id" = ? LIMIT 1  [["id", "35"]]
    Rendered resources/show.html.erb within layouts/login (0.8ms)
  Completed 200 OK in 93ms (Views: 90.5ms | ActiveRecord: 0.4ms)
  </code></pre>
  
  <p>I'd appreciate any help.</p>