README.textile in active_scaffold_duplicate-1.0.0 vs README.textile in active_scaffold_duplicate-1.0.1
- old
+ new
@@ -17,11 +17,11 @@
h2. Usage
h4. Step 1
-Override intialize_dup in the model:
+Override initialize_dup in the model to set some attributes or copy associations:
<pre>
# app/models/bill.rb
class Bill < ActiveRecord::Base
belongs_to :customer
@@ -46,36 +46,48 @@
end
</pre>
h4. Step 3
-Change method to :get in link if you want to display create form instead of cloning record.
+Change method to :get in link if you want to display create form instead of cloning record. Set position to :replace or :after for inline display, or enable page rendering.
<pre>
class BillsController < ApplicationController
active_scaffold do |conf|
- conf.duplicate.link.options.method = :get
+ conf.duplicate.link.method = :get
+ conf.duplicate.link.position = :after
+ #conf.duplicate.link.page = true # for new page rendering
end
end
</pre>
Also you can change it globally.
<pre>
class ApplicationController < ActionController::Base
active_scaffold.set_defaults do |conf|
- conf.duplicate.link.options.method = :get
+ conf.duplicate.link.method = :get
+ conf.duplicate.link.position = :after
+ #conf.duplicate.link.page = true # for new page rendering
end
end
</pre>
+You can access to record which is being duplicated in your form overrides with @old_record variable.
If you use :post method, you can enable refresh_list to refresh the list instead of only adding new record at top, or set action_after_clone to open edit form for example:
<pre>
conf.duplicate.refresh_list = true
conf.duplicate.action_after_clone = :edit
</pre>
+
+h2. Before/after controller methods
+
+It's possible to define some methods to add some custom code which require access to session or request params:
+
+* For :post method, before_duplicate_save(record) and after_duplicate_save(record) can be defined, which will be called before and after saving the record respectively.
+* For :new method, before_duplicate_new(record) can be defined, which will be called before rendering.
h2. Support
If you have issues installing the gem, search / post to the "Active Scaffold":http://groups.google.com/group/activescaffold forum or "Create an issue":http://github.com/activescaffold/active_scaffold_clone/issues