javascriptruby-on-railspostlink-to-remote

Rails 3 link_to method: :post, remote: true prototype


I'm in the process of upgrading a system to Rails 3.2 with Prototype.

I need to update the link_to_remote since it's now deprecated. I would like it to still use the AlertsController#create method.

The following link worked in Rails 2.3.15

link_to_remote 'example name', :update => "example id", :url => '/alerts?alert%5Bname%5D=MYNAME&commit=Create&inasset=true'

Neither of these seem to work in Rails 3.2. They both invoke AlertsController#index.

link_to 'example name', alerts_path("alert[name]" => 'MYNAME', :commit => "Create", :inasset => true), method: :post, update: "example id", remote: true

and

link_to 'example name', '/alerts/alert%5Bname%5D=MYNAME&commit=Create&inasset=true', method: :post, update: "example id", remote: true

My routes.rb has:

resources :alerts, except: :show

So my question is how should I update a link_to_remote tag in Rails 3.2, specifically one that depends on or calls the 'create' action.


Solution

  • You have rails.js in your manifest file(application.rb) ?, Normally it is the problem with javascript files included in your application, so inspect element in firefox and check the js files included in your head part.