active scaffold:如何在删除操作上设置确认文本?

时间:2011-11-15 06:21:33

标签: ruby-on-rails activescaffold

所以,我正在使用activescaffold并拥有以下代码:

config.actions = [:create, :delete, :list]
config.delete.link.confirm "Are you sure you want to delete this tag?"

根据我用Google搜索的内容,应该使删除链接确认框显示自定义文本...但它没有。它仍然使用一些默认问题文本。如何自定义确认文本?

3 个答案:

答案 0 :(得分:1)

它应该有用!

我已经开始使用git rep来共享与activescaffold相关的修复代码。

你可以在这里看到我的控制器: https://github.com/whizcreed/activescaffold-answers-to-stackoverflow/blob/master/app/controllers/notes_controller.rb

以下是正常运行的代码:

class NotesController < ApplicationController
  active_scaffold :notes  do  |config|
    config.columns = [:title, :content]
    config.delete.link.confirm = "Shows that you can change the confirm text  for delete!"
  end
end

我正在使用rails 2.3.10 和activescaffold分支:https://github.com/activescaffold/active_scaffold/tree/rails-2.3

我希望这会有所帮助。

答案 1 :(得分:1)

你错过了= 它应该是:

config.delete.link.confirm = "Are you sure you want to delete this tag?"

答案 2 :(得分:-1)

为什么不使用视图层来解决这个问题?

<%= button_to "Delete Foo", { :action => "delete", :id => @foo.id },
      :confirm => "For Real?!", :method => :delete %>

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html