ActiveAdmin and in-place editing

I have this system where I use ActiveAdmin to automate the backend, and I was wondering if anyone would try to use in-place editing with tables for ActiveAdmin.

I see some scenarios in which this would be useful: tables of key values โ€‹โ€‹(e.g. State, Category, etc.) and in master-detail views (Order and OrderItems) ...

Has anyone tried to implement it? Any good pointers?

+7
source share
2 answers

We used the best_in_place Editor, but only for custom views, and not for general ones.

https://github.com/bernat/best_in_place

gem "best_in_place" bundle rails g best_in_place:setup 

Add the best_in_place script to /app/assets/javascripts/active_admin.js :

 //= require best_in_place $(document).ready(function() { /* Activating Best In Place */ jQuery(".best_in_place").best_in_place() }); 

in your user view, in part, you can have something like

 .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] ... ... 

Since ActiveAdmin already configured your RESTful actions, and BestInPlace uses RESTful PUT to update too, everything should work automatically :)

You can also use something like this, but I have not tested this yet.

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

In fact, itโ€™s best to use the monkey patch to view Active Admin is very simple:

 # app/admin/active_admin/views.rb module ActiveAdmin::ViewHelpers extend BestInPlace::BestInPlaceHelpers end 
+5
source

All Articles