Created
August 27, 2011 19:09
-
-
Save cambridgemike/1175753 to your computer and use it in GitHub Desktop.
example usage of paper_trail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I envisage paper_trail being able to do this if you update the shelf before adding the second book.