Acts As Draftable plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_draftable/
This example class will create drafts on the title and body fields of Article:
class Article < ActiveRecord::Base acts_as_draftable :fields => [:title, :body] end
Here's a sample workflow:
1. Create your model.
article = Article.new(:title => 'foo', :body => 'bar')
2. Save draft.
article.save_draft
3. Retrieve latest draft.
draft = Article::Draft.find_new(:first, :order => 'updated_at desc')
4. Decide you like the draft, and save it.
article = draft.to_article article.save # notice your draft is now gone Article::Draft.find_new(:first, :order => 'updated_at desc') # => nil
5. Create a new draft from the saved article
article = Article.find(1) article.title # => 'foo' article.title = 'bar' article.save_draft
6. Load the draft's attributes over the current attributes without saving
article = Article.find(1) article.title # => 'foo' article.load_from_draft article.title # => 'bar'
7. Save the draft's attributes over the current attributes
article = Article.find(1) article.title # => 'foo' article.save_from_draft article.title # => 'bar'
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (1 older version) | Last edited by: scott, 10 months ago

