这看起来应该相对简单,但我在寻找答案时遇到了一些麻烦:
如何在 ActiveAdmin 中设置页面标题?
合并答案并添加一点:
这大部分都在维基百科上的这个页面 https://github.com/gregbell/active_admin/wiki/Set-page-title(或者我很快就会把它放在那里)。
在为 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)