Customize rails_admin to include self-created views and controllers

空扰寡人 提交于 2019-11-27 18:50:15

问题


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.



来源:https://stackoverflow.com/questions/8845480/customize-rails-admin-to-include-self-created-views-and-controllers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!