views:

21

answers:

1

I have a model Item:

class Item < ActiveRecord::Base
  acts_as_revisable
end

When I try to use Item.find(2, :with_revisions) it comes back as an ItemRevision class instead of an Item class and I can't do things like assigning from another model (i.e. ItemList.items << item).

Is there a way to make it return Item or a way to make it into an Item?

+1  A: 

When you have a revision object you can call a method on it to get what it's a revision for:

@page.revisions.first.page

In this example I have the Page model which has versions for its records, and on every version there is a page method to get the object to which that version references.

Ryan Bigg
Thank you very much. I could not figure this out for the life of me.
gir
Wait, that seems to return the current revision's object. If I were to do @page.find_revision(:previous).page it would give me @page assuming that @page was the current revision.
gir