I have a custom page in ActiveAdmin called statistics, where I want to display charts with data from the database.
Now I used the Gon gem and want to pass the data to my custom page through an instance variable.
Usually you would add the gon line to the index action
class ProductsController < ApplicationController
def index
gon.rabl "app/views/products/index.json.rabl", as: "products"
end
end
But there is no controller in active admin for my custom page. How should I do this?
Or do I have to do this through the dashboard?
Is your custom page being rendered from a ‘Resource’ controller ie from a resource that you have created in you application? If yes, then that is a controller itself. You can defined any custom action in the controller for the same.
And you can use the same strategy to pass data to your page as you do for partials ie by using the :locals