Last Updated: February 25, 2016
·
2.844K
· rebyn

Edit Rails records in-place like a spreadsheet

alt text

Ever want something like this for your app? Then read on.

First, put this into your Gemfile: gem "bestinplace"</code>

And: $ bundle</code>. Then, fire up your text editor, open assets/javascript/active_admin.js</code> and fill it with these lines:

+//= require jquery
+//= require jquery-ui
+//= require jquery.purr
+//= require best_in_place
 //= require active_admin/base
+$(document).ready(function() {
+  jQuery(".best_in_place").best_in_place();
+});

Open the Active Admin resource file, put these:

index do
      column :number_of_staff do |i|
        best_in_place i, :number_of_staff, type: :input, path: [:admin, i]
      end
end

with every field you want to enable in-place editing.

And you're good to go. Let me know if I can help.

Tu
qio.me/rebyn