简体   繁体   English

Rails 3 link_to方法::post,remote:true原型

[英]Rails 3 link_to method: :post, remote: true prototype

I'm in the process of upgrading a system to Rails 3.2 with Prototype. 我正在使用Prototype将系统升级到Rails 3.2。

I need to update the link_to_remote since it's now deprecated. 由于现在已弃用link_to_remote,因此我需要对其进行更新。 I would like it to still use the AlertsController#create method. 我希望它仍然使用AlertsController#create方法。

The following link worked in Rails 2.3.15 以下链接在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. 这些似乎都不能在Rails 3.2中工作。 They both invoke AlertsController#index. 它们都调用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: 我的routes.rb有:

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. 所以我的问题是我应该如何在Rails 3.2中更新一个link_to_remote标记,特别是依赖于或调用“ create”动作的标记。

您的清单文件(application.rb)中有rails.js,通常是应用程序中包含的javascript文件出现问题,因此请检查firefox中的元素并检查头部中包含的js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM