Adds an action to clone records, and support to clone rows in subforms.

Description

By default will only set attributes and belongs_to associations. You must override initialize_dup in your model or define a method to clone the record and set in conf.duplicate.method.

Duplicate rows in a subform, requires to set the :duplicate setting in the column’s options, or form_ui_options.

Installation

Add the following line to your Gemfile:

gem 'active_scaffold_duplicate'

Then run:

bundle install

Usage & Options

Enable the advanced search functionality in your controller:

class OrdersController < ApplicationController
  active_scaffold :order do |config|
    config.actions << :duplicate
  end
end

Example Code

class OrdersController < ApplicationController
  active_scaffold do |conf|
    conf.duplicate.link.method = :get
    conf.duplicate.link.position = :after
    #conf.duplicate.link.page = true # for new page rendering
    conf.columns[:lines].form_ui = nil, {duplicate: true} # add a button to duplicate a line in the subform
  end
end

Get Plugin