Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

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