【问题标题】:Change confirmation message on delete action on show page in active admin rails 4更改活动管理rails 4中显示页面上删除操作的确认消息
【发布时间】:2015-09-18 06:22:26
【问题描述】:

在我的应用程序中,我需要更改删除操作的默认确认消息。我已经更改了索引页面上删除操作的默认确认消息,例如,

index do
  column :title
  column :start_date
  column :start_time
  column :end_date
  column :end_time

  #actions
  actions defaults: false do |post|
    item "View", admin_content_path(post)
    text_node "&nbsp".html_safe
    item "Edit", edit_admin_content_path(post)
    text_node "&nbsp".html_safe
    item "Delete", admin_content_path(post), method: :delete, :confirm => "All grades, uploads and tracks will be deleted with this content.Are you sure you want to delete this Content?"
end

结束

这在索引页面上运行良好。 我还想更改显示页面上删除操作的默认确认消息。它仍然显示默认消息,例如“您确定要删除这个吗?”

以及如何更改activeadmin中批量操作确认对话框的css?

有人知道吗?谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 ruby-on-rails-5 activeadmin ruby-on-rails-6


    【解决方案1】:

    首先,你需要关闭默认生成的链接,你应该使用:

      config.clear_action_items!
    

    然后,您可以像这样创建自己的操作项

      action_item only: :show  do
        link_to "Delete", { action: :destroy }, method: :delete, data: { confirm: 'All grades, uploads and tracks will be deleted with this content.Are you sure you want to delete this Content?' }
      end
    

    【讨论】:

    • 谢谢。这就是我需要的
    • 我只面临一个问题。现在在显示页面上,我得到了两个删除按钮。但我只需要一个。那我该怎么做呢?
    • 那个配置去哪儿了?而如果配置是全局的,如何只在索引上做呢?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 2017-10-03
    • 1970-01-01
    • 2021-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多