gpt4 book ai didi

ruby-on-rails - 事件管理员:如何设置页面标题?

转载 作者:行者123 更新时间:2023-12-03 13:27:00 24 4
gpt4 key购买 nike

这似乎应该相对简单一些,但是在跟踪答案时遇到了一些麻烦:

如何在ActiveAdmin中设置页面标题?

最佳答案

合并答案并添加一些内容:

其中大多数在this page on the wiki上(或者我会尽快放在那里)。

在为activeadmin注册模型的文件中(例如app / admin / user.rb),您可以

ActiveAdmin.register User do
# a simple string
index :title => "Here's a list of users" do
...
end

# using a method called on the instance of the model
show :title => :name do
...
end

# more flexibly using information from the model instance
show :title => proc {|user| "Details for "+user.name } do
...
end

# for new, edit, and delete you have to do it differently
controller do
def edit
# use resource.some_method to access information about what you're editing
@page_title = "Hey, edit this user called "+resource.name
end
end
end

关于ruby-on-rails - 事件管理员:如何设置页面标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16905616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com