自定义 rails_admin 以包含自创建的视图和控制器 [英] Customize rails_admin to include self-created views and controllers

查看:44
本文介绍了自定义 rails_admin 以包含自创建的视图和控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用 rails_admin 引擎,但不太明白如何向其中添加自己的页面.我的要求正是我有一个控制器和视图,可以获取所有可用的 mongoDb 集合并显示在

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

是否有可能以某种方式将这个视图与 rails admin 合并,以便我得到一个链接

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

http://localhost:3000/admin/mongo

我没有使用 ActiveRecords 或模型.我正在从 HTTP 请求中获取数据并显示它.理想情况下,我的页面需要一个位于默认仪表板选项卡下方的选项卡.提前致谢.

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.

推荐答案

如果您想将其显示为选项卡,请查看 RailsAdmin 的新 自定义操作.

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:

  • 将路由映射到您的控制器和操作
  • 让您的控制器继承自 RailsAdmin MainController 并为您的操作编写代码
  • 为您的操作添加一个视图
  • 复制 RailsAdmin 视图以将其添加为选项卡

但是,我建议使用自定义操作方法,因为它不需要您更新复制的 RailsAdmin 视图.

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

这篇关于自定义 rails_admin 以包含自创建的视图和控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆