title: Probleme on update, save and delete between Backbone and Rails
body: <p>I'm trying to create an application with backbone, on the client side, and Rails on the server side. It works but I have a problem on create, update and destroy.</p>
  
  <p>I'm doing this :</p>
  
  <pre><code>m = new MyFirstProjectServer.Models.Inquiry({id: 1})
  m.fetch() #work fine
  m.set({title: 'title', description: 'description'}) 
  m.save() #don't work
  </code></pre>
  
  <p>An ajax call is done on save :</p>
  
  <pre><code>Access-Control-Allow-Head...    X-Requested-With, X-Prototype-Version
  Access-Control-Allow-Meth...    POST, GET, OPTIONS, PUT
  Access-Control-Allow-Orig...    *
  Access-Control-Max-Age  1728000
  Cache-Control   no-cache
  Connection  Keep-Alive
  Content-Length  0
  Content-Type    text/plain; charset=utf-8
  Date    Sat, 13 Oct 2012 22:27:33 GMT
  Server  WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
  X-Request-Id    a5b58b91a95b72f30849d39db0f0358f
  X-Runtime   0.002259
  x-ua-compatible IE=Edge
  Requêtevoir le code source
  Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding gzip, deflate
  Accept-Language en-US,en;q=0.5
  Access-Control-Request-He...    content-type
  Access-Control-Request-Me...    PUT
  Connection  keep-alive
  Host    192.168.20.101:3000
  Origin  http://localhost:4567
  User-Agent  Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0
  </code></pre>
  
  <p>The request is handled on the server side :</p>
  
  <pre><code>Started OPTIONS "/inquiries/2" for 192.168.20.101 at 2012-10-13 18:27:33 -0400
  Processing by InquiriesController#options as HTML
    Parameters: {"id"=&gt;"2"}
    Rendered text template (0.0ms)
  Completed 200 OK in 0ms (Views: 0.3ms | ActiveRecord: 0.0ms)
  </code></pre>
  
  <p>Finaly, it thrown this error on save callback :</p>
  
  <pre><code>readyState 0
  responseText ""
  status 0
  statusText "error"
  </code></pre>
  
  <p>This is my controller :</p>
  
  <pre><code>class InquiriesController &lt; ApplicationController
    ...
    def show
      render json: Inquiry.find(params[:id])
    end
  
    def create
      @inquiry = Inquiry.new(params[:inquiry])
      if @inquiry.save
        render json: @inquiry, status: :created, location: @inquiry
      else
        render json: @inquiry.errors, status: :unprocessable_entity
      end
    end
    ...
  
    def options
      headers['Access-Control-Allow-Origin'] = '*'
      headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT. DELETE'
      headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'
      headers['Access-Control-Max-Age'] = '1728000'
      render :text =&gt; '', :content_type =&gt; 'text/plain'
    end
  end
  </code></pre>
  
  <p>I have this on the ApplicationController :</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    after_filter :cors_set_access_control_headers
  
    protected
    def cors_set_access_control_headers
      headers['Access-Control-Allow-Origin'] = '*'
      headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT'
      headers['Access-Control-Max-Age'] = "1728000"
    end
  end
  </code></pre>
  
  <p>This is my routes :</p>
  
  <pre><code>MyFirstProjectServer::Application.routes.draw do
    get "main/index"
    root to: "main#index"
  
    resources :inquiries
    match '/inquiries', controller: :inquiries, action: :options, constraints: {method: 'OPTIONS'}
    match '/inquiry', controller: :inquiries, action: :options, constraints: {method: 'OPTIONS'}
    match '/inquiry/:id', controller: :inquiries, action: :options, constraints: {method: 'OPTIONS'}
    match '/inquiries/:id', controller: :inquiries, action: :options, constraints: {method: 'OPTIONS'}
  end
  </code></pre>
  
  <p>And finaly, this is my model :</p>
  
  <pre><code>class MyFirstProjectServer.Models.Inquiry extends Backbone.Model
    urlRoot:"http://192.168.20.101:3000/inquiries/"
  </code></pre>
  
  <p>Do you have a solution?</p>
  
  <p>Thanks!</p>