2013-03-05 35 views
0

我正在使用Prototype将系统升级到Rails 3.2。Rails 3 link_to方法::post,remote:true prototype

我需要更新link_to_remote,因为它现在已被弃用。我希望它仍然使用AlertsController#create方法。

下面的链接中的Rails 2.3.15工作

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

这些都不似乎对Rails 3.2的工作。它们都调用AlertsController#index。

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

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

我的routes.rb有:

resources :alerts, except: :show 

所以我的问题是我应该如何更新的Rails 3.2 link_to_remote标签,特别是一个依赖于或来电'创造'行动。

回答

0

你的清单文件(application.rb)中有rails.js?,通常这是包含在你的应用程序中的JavaScript文件的问题,所以检查firefox中的元素并检查包含在你头部的js文件。

+0

好的,谢谢。我明天会检查这个。 – alaup 2013-03-06 23:16:27

+0

是的,它没有rails.js文件。 此外,最新的rails.js使用document.on(),我不得不使用旧版本[这里](https://github.com/rails/rails/blob/91d1012a98975979473709adf723a94057bda295/railties/lib/rails/generators /rails/app/templates/public/javascripts/rails.js)。 – alaup 2013-03-20 20:42:07