【问题标题】:Set the title of Custom Pages in ActiveAdmin在 ActiveAdmin 中设置自定义页面的标题
【发布时间】:2019-01-25 18:02:58
【问题描述】:

我正在寻找有关如何使用modify the title 或ActiveAdmin Custom page 的信息,但没有任何效果。我发现的解决方案仅适用于标准 ActiveAdmin 页面。

比如我的Report页面

ActiveAdmin.register_page "report" do
  controller do
    before_action { @page_title = "Generación de reportes" }
  end

  menu label: 'Generación de reportes'

  content do
    render partial: 'report'
  end
end

显示标准标题,它与注册时使用的字符串相同。

有没有一种方法可以自定义标题,例如“Generación de reportes”之类的内容?

【问题讨论】:

  • 你的 rails 和 activeadmin 版本是什么?
  • @JavierMenéndezRizo rails 5.2.2 和 activeadmin 1.4.3

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


【解决方案1】:

在your provided link 中,您有以下选项来修改页面标题:

content 'title': Proc.new {
  @page_title = 'Your title'
} do
 ...
end

或其他选项,根据文档:

content title: "Your Title" do
 ...
end

根据文档,您必须在 same link! 中看到“自定义页面标题栏中的图像或链接”!

您在注册controller 时使用before_action,但在提供的代码中,您正在注册page。

希望这会有所帮助!

【讨论】:

  • 是的,这行得通!你可以像这样直接提供标题作为值:content title: title_value do your_code end
  • 至少在我的情况下它适用于content title: "title" do ... end。 Proc.new { ... blah blah blah 没用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多