You are here: Browse Railsplugins Acts As Draftable
Allows a model to save certain attributes into a smaller drafts table. These are meant to be temporary modifications until the actual model is saved. This is very similar to Acts as Versioned.
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
5. Create a new draft from the saved article
article = Article.find(1) article.title6. Load the draft’s attributes over the current attributes without saving
article = Article.find(1) article.title7. Save the draft’s attributes over the current attributes
article = Article.find(1) article.titleNOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly