ActiveAdmin 和就地编辑
我有一个系统,我使用 ActiveAdmin 来自动化后端,我想知道是否有人尝试对 ActiveAdmin 的表进行就地编辑。
我看到一些有用的场景:键值表(如状态、类别等)和主从视图(订单和订单项)...
有人尝试实现它吗?有什么好的指点吗?
I have this system where I use ActiveAdmin to automate the backend and I was wondering if anyone tried to use in-place editing with tables for ActiveAdmin.
I see some scenarios where that would be useful: key-value tables (like State, Category, etc.) and in master-detail views (Order and OrderItems)...
Have anyone attempted to implement it? Any good pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们使用了 best_in_place 编辑器,但仅限于自定义视图,而不是通用视图。
https://github.com/bernat/best_in_place
将 best_in_place 脚本添加到
/app/assets /javascripts/active_admin.js
:在您的自定义视图部分中,您可以有类似的内容,
因为 ActiveAdmin 已经设置了您的 RESTful 操作,并且 BestInPlace 也正在使用 RESTful PUT 进行更新,所以一切都应该自动工作:)
你也可以使用类似的东西,但我还没有测试过。
We've used best_in_place Editor but only on customized views, not on generic ones.
https://github.com/bernat/best_in_place
Add the best_in_place script to
/app/assets/javascripts/active_admin.js
:in your custom view partial you can have something like
As ActiveAdmin has already setup your RESTful Actions and BestInPlace is using RESTful PUT to Update too, everything should work automatically :)
You may can also use something like this, but I've not tested this yet.
实际上,用于 Active Admin 视图的 Best In Place 猴子补丁非常简单:
Actually Best In Place monkey patch for Active Admin views is very easy: