ActiveAdmin和就地编辑

我有这个系统,我使用ActiveAdmin自动化后端,我想知道是否有人尝试使用ActiveAdmin的表进行就地编辑。

我看到一些有用的场景:键值表(如State,Category等)和master-detail视图(Order和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操作,而BestInPlace也使用RESTful PUT进行更新,所以一切都应该自动运行:)

你也可以使用这样的东西,但我还没有测试过。

 index do column(:name) { |i| best_in_place i, :name, :type => :input, :path => [:admin, i] } end 

实际上,针对Active Admin视图的Best In Place猴子补丁非常简单:

 # app/admin/active_admin/views.rb module ActiveAdmin::ViewHelpers extend BestInPlace::BestInPlaceHelpers end 
Interesting Posts