弃用警告::不推荐使用confirm选项,将从Rails 4.0中删除。使用':data => {:confirm => '文字'}'而不是

时间:2012-07-05 21:54:28

标签: ruby-on-rails-3

我已将rails示例应用程序从3.1版升级到3.2.6版。不幸的是,我有以下弃用警告。

DEPRECATION WARNING: :confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => 'Text' }' instead. (called from _app_views_shared__feed_item_html_erb___1282539180373198927_70193136005180 at /Users/Bart/rails_projects/sample_app/app/views/shared/_feed_item.html.erb:27)

期待解决这个问题。

祝你好运

1 个答案:

答案 0 :(得分:12)

此警告的读取方式,您需要编辑共享/ _feed_item.html.erb视图的第27行。这是

的简单改变
link_to 'Do Something', some_path, :confirm => 'Text'

link_to 'Do Something', some_path, :data => { :confirm => 'Text' }

或更新的Rails 1.9语法:

link_to 'Do Something', some_path, data: { confirm: 'Do you really want to do something?' }

以下是指向已弃用的Rails commitRails team's discussion的链接。