0

Possible Duplicate:
Weird “406 not acceptable” error

I receive a "406 Not acceptable" error after doing a respond_to with a format.js. This is the link:

    <%= link_to I18n.t(:alert_dismiss), :controller => 'alerts', :action => 'dismiss', :id => @alert, :remote => :true %>

This is the dismiss action from the alerts controller:

  # Sets alert dismiss status to true
  def dismiss
    # Get alert data
    @alert = Alert.find(params[:id])

    # Update status
    @alert.update_attribute(:dismiss, true)
    @alert.save!

    respond_to do |format|
      format.js
    end

  end

And this is dismiss.js.erb:

$('.systemalert').empty();

Any idea what's wrong? Thanks!

Community
  • 1
  • 1
John
  • 6,404
  • 14
  • 54
  • 106

2 Answers2

3

Change :true to true

Also remove save! as update_attribute does that.

Thilo
  • 17,565
  • 5
  • 68
  • 84
ants
  • 1,097
  • 1
  • 7
  • 13
  • Changing true made no difference unfortunately. – John Feb 07 '12 at 16:18
  • Have you tried tidying up your route because apart from the `:true`, the request looks okay. In routes, try `match 'alerts/dismiss/:id' => 'alerts#dismis', :as => 'dismiss_alert', :via => :get`. Then you can use `dismiss_alert_path(@alert)` in your `link_to` – ants Feb 07 '12 at 16:53
0

Instead!! This worked for me:

  render "users/invitations/createRequestInvite.js"
dbKooper
  • 1,035
  • 10
  • 17