title: Rails Completed 406 Not Acceptable in 64ms
body: <p>I have a form on my website with a page where I can edit / remove / add mailboxes:</p>
  
  <ul>
  <li><a href="http://example.com/settings/mailboxes" rel="nofollow">http://example.com/settings/mailboxes</a></li>
  <li><a href="http://example.com/settings/mailboxes/3/edit" rel="nofollow">http://example.com/settings/mailboxes/3/edit</a></li>
  <li><a href="http://example.com/settings/mailboxes/3" rel="nofollow">http://example.com/settings/mailboxes/3</a></li>
  <li>etc.</li>
  </ul>
  
  <p>Whenever I do something to the mailbox (update, destroy) I'm getting this error:</p>
  
  <blockquote>
    <p>Redirected to <a href="http://example.com/" rel="nofollow">http://example.com/</a>
    Completed 406 Not Acceptable in 64ms</p>
  </blockquote>
  
  <p>But the data gets updated.</p>
  
  <p>Here's the controller code:</p>
  
  <pre><code># PUT /mailboxes/1
  def update
    @mailbox = Mailbox.find(params[:id])
  
    if @mailbox.update_attributes(params[:mailbox])
      redirect_to(root_path, :notice =&gt; 'Mailbox was successfully updated.')
    else
      render :action =&gt; "edit"
    end
  end
  
  # DELETE /mailboxes/1
  def destroy
    @mailbox = Mailbox.find(params[:id])
    @mailbox.destroy
  
    redirect_to(root_path)
  end
  </code></pre>
  
  <p>Here's routes.rb info:</p>
  
  <pre><code>match 'settings.js' =&gt; 'settings#javascript', :via =&gt; :get, :format =&gt; :js
  scope '/settings' do
  
    # Directs /settings/mailboxes/* to Settings::MailboxesController
    # (app/controllers/settings/mailboxes_controller.rb)
    resources :mailboxes     
  end
  </code></pre>
  
  <p>What am I doing wrong? Here's what log shows:</p>
  
  <pre class="lang-none prettyprint-override"><code>if @mailbox.update_attributes(params[:mailbox])
  (rdb:2) response.status
  200
  (rdb:2) next
  /Users/Fallen/Projects/support-app/trunk/app/controllers/mailboxes_controller.rb:65
  redirect_to(mailboxes_path, :notice =&gt; 'Mailbox was successfully updated.') 
  (rdb:2) response.status
  200
  (rdb:2) next
  /usr/local/rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_controller/metal/implicit_render.rb:5
  default_render unless response_body
  (rdb:2) response_body
  [" "]
  (rdb:2) response.status
  406
  (rdb:2) cont
  
  
  Started PUT "/settings/mailboxes/5" for 127.0.0.1 at 2011-10-14 12:54:38 +0200
    Status Load (0.4ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`name` = 'Incoming emails fetching' LIMIT 1
     (0.1ms)  BEGIN
     (0.4ms)  UPDATE `statuses` SET `last_action_at` = '2011-10-14 10:54:38' WHERE `statuses`.`id` = 1
     (39.6ms)  COMMIT
    Processing by MailboxesController#update as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"0cip2dsYre9anfy/8rEgtuYcgrgC3si6aSuppjzxuHU=", "mailbox"=&gt;{"name"=&gt;"Dev Support #4", "sender_name"=&gt;"example.com Support #4", "email_address"=&gt;"support_dev4@example.com", "color"=&gt;"B2EB3D"}, "commit"=&gt;"Update Mailbox", "id"=&gt;"5"}
    Mailbox Load (0.5ms)  SELECT `mailboxes`.* FROM `mailboxes` WHERE `mailboxes`.`id` = 5 LIMIT 1
    Status Load (0.5ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`name` = 'Incoming emails fetching' LIMIT 1
     (0.1ms)  BEGIN
     (0.3ms)  UPDATE `statuses` SET `last_action_at` = '2011-10-14 10:54:47' WHERE `statuses`.`id` = 1
     (0.4ms)  COMMIT
     (0.2ms)  BEGIN
     (0.6ms)  UPDATE `mailboxes` SET `color` = 'B2EB3D', `updated_at` = '2011-10-14 10:54:48' WHERE `mailboxes`.`id` = 5
    Mailbox Load (0.7ms)  SELECT `mailboxes`.* FROM `mailboxes` 
     (1.2ms)  COMMIT
    Mailbox Load (0.4ms)  SELECT id, name, open_tickets_count FROM `mailboxes` 
     (0.3ms)  SELECT COUNT(*) FROM `tickets` WHERE `tickets`.`closed` = 0
    CACHE (0.0ms)  SELECT COUNT(*) FROM `tickets` WHERE `tickets`.`closed` = 0
  Redirected to http://localhost:3000/settings/mailboxes
  Completed 406 Not Acceptable in 29008ms
  </code></pre>