我有这个系统,我使用ActiveAdmin来自动化后端,我想知道是否有人试图使用ActiveAdmin的表就地编辑。ActiveAdmin和in-place编辑
我看到的一些情形,这将是有益的:键值表(如国家,类别等),并在主详细的意见(订单和的OrderItems)...
有任何人企图实施它?任何好的指针?
我有这个系统,我使用ActiveAdmin来自动化后端,我想知道是否有人试图使用ActiveAdmin的表就地编辑。ActiveAdmin和in-place编辑
我看到的一些情形,这将是有益的:键值表(如国家,类别等),并在主详细的意见(订单和的OrderItems)...
有任何人企图实施它?任何好的指针?
我们已经使用了best_in_place编辑器,但仅限于自定义视图,而不是通用的视图。
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() });
在您的自定义视图部分,你可以有类似
.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 Actions和BestInPlace正在使用RES Tful PUT来更新,一切都应该自动工作:)
你也可以使用类似的东西,但我还没有测试过。
index do
column(:name) { |i| best_in_place i, :name, :type => :input, :path => [:admin, i] }
end
其实最好的地方猴子补丁主动管理的意见很简单:
# app/admin/active_admin/views.rb
module ActiveAdmin::ViewHelpers
extend BestInPlace::BestInPlaceHelpers
end
仍然适用于3.1.0,但您希望'BestInPlace :: Helper' – sbeam
我已成功地使用同样的插件在通用的,具有轻微的变化。当我停止懒惰时,不妨做一篇博客文章:)谢谢! – kolrie
这太棒了。 @kolrie我感兴趣的是如何让它与通用的一起工作,你是否需要对ActiveAdmin进行猴子补丁? – David
太棒了。也为我工作。 – RailsTweeter