title: ActionController::UnknownFormat
body: <p>In my rails app I have a ajax request to the server, to store some data. This used to work without any problem, but now I get an error:</p>
  
  <pre><code>ActionController::UnknownFormat (ActionController::UnknownFormat):
    app/controllers/reservations_controller.rb:45:in `create'
  </code></pre>
  
  <p>As following is the controller and my javascript file where I declare the datatype do be JSON</p>
  
  <pre><code>class ReservationController &lt; ApplicationController
  
    respond_to :html, :json
  
    def create
      ...
      respond_to do |format|
        if @reservation.save
          format.html do
            redirect_to '/'
          end
          format.json { render json: @reservation.to_json }
        else
          render 'new'
        end
      end # respond_to
    end # create 
  end # ReservationController
  </code></pre>
  
  <p>function.js</p>
  
  <pre><code>$.ajax({
          url: url_link,
          dataType: 'json',
          type: 'POST',
          data: dataToSend
        })
  </code></pre>
  
  <p>The complete error log is:</p>
  
  <pre><code>Completed 406 Not Acceptable in 45ms
  
  ActionController::UnknownFormat (ActionController::UnknownFormat):
  app/controllers/bookings_controller.rb:45:in `create'
  
  Rendered /Users/tiagovieira/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
  Rendered /Users/tiagovieira/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
  Rendered /Users/tiagovieira/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
  Rendered /Users/tiagovieira/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.6ms)
  </code></pre>