我有一个系统,使用ActiveAdmin自动化后端,我想知道是否有人尝试在ActiveAdmin中使用表格进行原地编辑。
我看到一些场景会用到它:键值表(例如State、Category等)和主从视图(Order和OrderItems)...
有没有人尝试过实现它?有什么好的指点?
我有一个系统,使用ActiveAdmin自动化后端,我想知道是否有人尝试在ActiveAdmin中使用表格进行原地编辑。
我看到一些场景会用到它:键值表(例如State、Category等)和主从视图(Order和OrderItems)...
有没有人尝试过实现它?有什么好的指点?
gem "best_in_place"
bundle
rails g best_in_place:setup
/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也使用RESTful 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
BestInPlace::Helper
。 - sbeam