Is there a way to have multiple dashboards for the same model depending on scope? A simple example would be if I had a Task model, where status is an enum of [:planned, :doing, :done].
I'd like to have a dashboard for all my tasks that are currently planned, one for doing and one dashboard for done.
What's the current approach for doing this? Thanks!
From the top of my head, I think this should be possible by creating three (or as many) models that inherit from Task, and are differentiated using Single Table Inheritance on the status column.
Also I'm looking at /app/controllers/administrate/application_controller.rb, and thinking that it might be possible to do this by overriding scoped_resource on each of the three controllers, to return only the appropriate scope. I'm not 100% sure though, as there might be other methods that need to be overridden, of those currently delegated to resource_resolver.
Could you try if one of these work, and let us know? :-)
I'm going to close this for now, as I don't think it is a bug. Please let us know how it went in any case.
One way that I achieved this was to include a URL query parameter that mapped to a scope name defined in my model. Then, in the ModelController#scoped_resource you can do as follows:
def scoped_resource
if params['status']
return resource_class.send(params['status'])
end
resource_class
end
Of course, you should use Strong Parameters to ensure that only whitelisted values make it through. Now, I can create links in my nav or in buttons on my dashboard pages that I can use to GET these routes with the appropriate scopes.
Thanks @stevenbuccini. I will try this the next chance I get.