Customize rails_admin to include self-created view

2019-02-10 13:22发布

问题:

I started using rails_admin engine lately and can't quite figure out how I can add my own pages to it. My requirement exactly is that I have a controller and view that fetches all the available mongoDb collections and displays at

http://localhost:3000/mongo/collections

Is it possible to merge this view somehow with rails admin so that I get a link as

http://localhost:3000/admin/mongo

I am not using ActiveRecords or models. I'm fetching the data from HTTP request and displaying it. Ideally, I need a tab for my page just below the default dashboard tab. Thanks in advance.

回答1:

If you want to display this as a tab, take a look at RailsAdmin's new custom actions.

I just gave some examples and links in my answer to this question.


If you don't want to add this functionality as a custom action, you can:

  • Map a route to your controller & action
  • Have your controller inherit from RailsAdmin MainController and write code for your action
  • Include a view for your action
  • Copy a RailsAdmin view over to add it in as a tab

However, I'd recommend the custom action approach because it does not require you to keep your copied RailsAdmin view updated.