活动管理 - 非资源相关控制器
你好,我尝试在活动管理中实现一个自己的控制器+它需要继承活动管理的页脚/页眉/面包屑
我需要一个自己的模板文件来执行常规索引操作...传递参数以显示相关统计信息(我会使用谷歌图表API在模板中渲染它们)
我遇到的问题是没有办法从头开始期望侧边栏对我有很大帮助..
我需要在该视图上显示7个不同的图表,
我真的很欣赏任何想法,因为这让我发疯,
谢谢皮埃尔
Hy there, i try to implement a own controller into active admin + it would neet to inherit the footer / header / breadcrumbs of active admin
i need a own template file for the regular index action ... passing a parameter in to show related stats ( i would render them in the template using google chart api)
the issue i came accross is there is no way todo that from scratch expect sidebars which wont help me alot ..
i need to display like 7 different charts on that view
i realy appreciate any idea since it drives me insane
thanks Pierre
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
进一步之前的答案。您甚至不需要定义真实的模型(在您的模型文件夹中)。
完成这项工作所需的最少代码是:
全部在一个文件中: app/admin/charts.rb
我将其用于以下要点:
https://gist.github.com/1644526
Further to the previous answer. You don't even need to define a real model (in your models folder).
The minimum code I needed to get this working was:
All in the one file: app/admin/charts.rb
I used it for this gist:
https://gist.github.com/1644526
这对我有用,只需在代码块中替换 ViewLogger 的正确名称即可。这样您就不必在数据库中创建虚拟表。
使用此内容创建一个文件 /app/models/viewlogger.rb ,对于更高级的无表模型,您可能需要查看 http ://keithmcdonnell.net/activerecord_tableless_model_gem.html 或一起在 Google 上搜索您自己的见解。
添加一个条目到 /config/initializers/inflections.rb
在 config/routes.rb 中为您的视图记录器设置一条路线:
现在您可以按如下所示制定 activeadmin 注册块(确保您在正确的位置创建了一个视图部分)
结尾
This is what worked for me, just substitute the right name for ViewLogger in the codeblocks. This way you wont have to create a dummy table in your database.
Make a file /app/models/viewlogger.rb with this contents, for more advanced tableless models you might want to check out http://keithmcdonnell.net/activerecord_tableless_model_gem.html or google your own insight together.
add an entry to /config/initializers/inflections.rb
set up a route for your viewlogger, in config/routes.rb:
now you can formulate the activeadmin register block as follows (make you sure you create a view partial in the right place)
end