活动脚手架:如何设置删除操作的确认文本?

发布于 2024-12-15 21:29:47 字数 255 浏览 2 评论 0原文

因此,我正在使用 activescaffold 并具有以下代码:

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

根据我在谷歌上搜索的内容,应该使删除链接确认框显示该自定义文本...但事实并非如此。它仍然使用一些默认的问题文本。如何自定义确认文本?

So, I'm using activescaffold and have the following code:

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

which according to what I've googled should make the delete link confirmation box display that custom text... but it doesn't. It still uses some default question text. How can I customize the confirmation text?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终弃我 2024-12-22 21:29:47

它应该有效!

我已经启动了 git 代表来共享与 activescafold 相关的修复代码。

您可以在这里看到我的控制器:
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

我是使用导轨 2.3.10
和 activescaffold 分支: https://github.com/activescaffold/active_scaffold/tree/rails-2.3

我希望这有帮助。

It should work!

I have started a git rep to share code with fixes related to activescaffold.

You can see my controller here:
https://github.com/whizcreed/activescaffold-answers-to-stackoverflow/blob/master/app/controllers/notes_controller.rb

And here is the code that works correctly:

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

I am using rails 2.3.10
and activescaffold branch: https://github.com/activescaffold/active_scaffold/tree/rails-2.3

I hope this helps.

左耳近心 2024-12-22 21:29:47

您缺少 =
应该是:

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

you are missing the =
it should be:

config.delete.link.confirm = "Are you sure you want to delete this tag?"
假面具 2024-12-22 21:29:47

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

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

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

Why not approach this problem using the view layer?

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文