I'm using active admin and I'd like to get the nested resource in the index title for optional nested resource, for example for the route:
For example I will have two models set up like this:
ActiveAdmin.register Document do
end
ActiveAdmin.register Comment do
belongs_to :doucment, optional: true
index title: 'GET DOCUMENT HERE IF ON NESTED ROUTE' do
end
end
How on earth do I access the parent doucment in the index title? I've tried every possible thing I can think of going over the objects available there and can't find how to do this in the docs as well. I've even tried to get the curren url to see if it has docuemnts in it, however routing is not available as well here.
Thanks very much for your help.
You can set the title with a proc
like this:
index(
title: proc {
if params[:document_id].present?
"#{Document.find(params[:document_id])}"
else
"It was optional all along"
end
}
) do
# ...
end