Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
example usage of paper_trail
# Parent class
class bookshelf
has_many :books
# Child class
class book
belongs_to :bookshelf
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"]

This comment has been minimized.

Copy link

@airblade airblade commented Aug 31, 2011

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