Skip to content

Instantly share code, notes, and snippets.

@cambridgemike
Created August 27, 2011 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cambridgemike/1175753 to your computer and use it in GitHub Desktop.
Save cambridgemike/1175753 to your computer and use it in GitHub Desktop.
example usage of paper_trail
# Parent class
class bookshelf
has_many :books
has_paper_trail
end
# Child class
class book
belongs_to :bookshelf
has_paper_trail
end
shelf = Bookshelf.create
shelf.books.create :title => "tale of two cities"
shelf.books # [#<Book id:1 title:"tale of two cities"]
shelf.books.create :title => "catcher in the rye"
shelf.books # [#<Book id: 1 title:"tale of two cities">, #<Book id:2 title:"catcher in the rye">]
shelf.previous_version.books # [#<Book id:1 title:"tale of two cities"]
@airblade
Copy link

I envisage paper_trail being able to do this if you update the shelf before adding the second book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment