我有这个系统,我使用 ActiveAdmin 来自动化后端,我想知道是否有人试图对 ActiveAdmin 的表使用就地编辑。
我看到了一些有用的场景:键值表(如状态、类别等)和主从 View (订单和订单项)...
有没有人尝试实现它?有什么好的指点吗?
最佳答案
我们使用了 best_in_place Editor,但仅用于自定义 View ,而不是通用 View 。
https://github.com/bernat/best_in_place
gem "best_in_place"
bundle
rails g best_in_place:setup
将 best_in_place 脚本添加到
/app/assets/javascripts/active_admin.js
://= require best_in_place
$(document).ready(function() {
/* Activating Best In Place */
jQuery(".best_in_place").best_in_place() });
在您的自定义 View 部分中,您可以拥有类似的东西
.panel
%h3 Your Resource Table
.panel_contents
.attributes_table
%table
%tbody
%tr
%th Name
%td= best_in_place resource, :name, :type => :input, :path => [:admin, resource]
...
...
由于 ActiveAdmin 已经设置了您的 RESTful 操作并且 BestInPlace 也在使用 RESTful PUT 进行更新,所以一切都应该自动运行:)
你也可以使用这样的东西,但我还没有测试过。
index do
column(:name) { |i| best_in_place i, :name, :type => :input, :path => [:admin, i] }
end
关于ruby-on-rails - ActiveAdmin 和就地编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7689747/