# Vestal Versions and attr\_accessors

**URL:** <https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750>\
**Category:** Rails\
**Created:** [January 13, 2011, 9:07pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750 "2011-01-13T21:07:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 13, 2011, 9:07pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750/1 "2011-01-13T21:07:11Z")

</div>

If I define an attr\_accessor in my model, can I somehow get Vestal  
Versions to track changes to the value of these? I’m specifically trying  
to get these “synthetic” object properties to be stored in the version  
diff, along with the regular column-backed properties.

Has anyone done anything like this? Any tips to offer?

Thanks in advance,

Walter

---

<div class="post-metadata">

**Author:** ![walterdavis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a587f6/32.png) [@walterdavis](https://www.ruby-forum.com/u/walterdavis)\
**Post date:** [January 13, 2011, 9:08pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750/2 "2011-01-13T21:08:43Z")

</div>

Walter D. wrote in post #974734:

> If I define an attr\_accessor in my model, can I somehow get Vestal  
> Versions to track changes to the value of these? I’m specifically trying  
> to get these “synthetic” object properties to be stored in the version  
> diff, along with the regular column-backed properties.

That sounds insane. If a property is worth tracking, isn’t it worth  
storing in the database?

Can you give an example of one of these properties?

> Has anyone done anything like this? Any tips to offer?
> 
> Thanks in advance,
> 
> Walter

## Best,

Marnen Laibow-Koser

> **[marnen.org: Homepage of Marnen Laibow-Koser](https://marnen.org/)**

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![walterdavis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a587f6/32.png) [@walterdavis](https://www.ruby-forum.com/u/walterdavis)\
**Post date:** [January 13, 2011, 9:38pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750/3 "2011-01-13T21:38:46Z")

</div>

On Jan 13, 2011, at 3:08 PM, Marnen Laibow-Koser wrote:

> > Versions to track changes to the value of these? I’m specifically  
> > trying  
> > to get these “synthetic” object properties to be stored in the  
> > version  
> > diff, along with the regular column-backed properties.
> 
> That sounds insane. If a property is worth tracking, isn’t it worth  
> storing in the database?
> 
> Can you give an example of one of these properties?

Sure. I have an Approval, which is a sort of loosely-coupled join  
model between a Role and an Ad. Ads are versioned, and each time I  
make a new version of an Ad (to update the artwork or similar) I need  
to store the current graph of approvals for historical purposes only.  
(Who had approved it already, who hadn’t.)

I allow the users to step back through time to see the evolution of an  
ad, and I need to show where it stood at each point. But changing the  
approvals doesn’t update the version of an ad, only updating the  
artwork does. So I was thinking that I could record the current state  
– as a snapshot – just before I saved the version and then play it  
back whenever the version did not equal the last version.

Is there a simpler way to do this? I have already wasted a lot of time  
trying to version associated records in VV, and it’s made me very  
cranky.

Walter

---

<div class="post-metadata">

**Author:** ![walterdavis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a587f6/32.png) [@walterdavis](https://www.ruby-forum.com/u/walterdavis)\
**Post date:** [January 13, 2011, 10:55pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750/4 "2011-01-13T22:55:27Z")

</div>

On Jan 13, 2011, at 4:20 PM, Marnen Laibow-Koser wrote:

> > I allow the users to step back through time to see the evolution of  
> > an  
> > ad, and I need to show where it stood at each point. But changing the  
> > approvals doesn’t update the version of an ad, only updating the  
> > artwork does.
> 
> So do you need to show the user different Approvals for one version of  
> an Ad?

Each time I save a new version of an Ad, I completely reset all of the  
approvals. The _last_ version was approved, but this is a _new_  
version, and it might have regressed in someone’s opinion. So the  
current association says that nothing is approved immediately after  
updating the ad. But a user might want to look back a few versions,  
and see who approved it then. I don’t want this historical data to be  
live – able to be changed – I just need it to be stored and played  
back in some frozen form.

> > So I was thinking that I could record the current state  
> > – as a snapshot – just before I saved the version and then play it  
> > back whenever the version did not equal the last version.
> > 
> > Is there a simpler way to do this?
> 
> Almost certainly. You sound like you’re trying to add complexity when  
> you could just be working through the object graph and associations.

The associations are always current – they relate only the the most  
recent version of the ad. Once I step backward in the Ad’s version  
trail, they are no longer accurate.

> > I have already wasted a lot of time  
> > trying to version associated records in VV, and it’s made me very  
> > cranky.
> 
> I don’t know if VV does association versions, but there are other gems  
> that do – I seem to recall that acts\_as\_revisable is one.

I’ve tried a bunch of other gems that purported to do this, not sure  
if this was one I tried. I’ll give it a look, though. Without some way  
to stick the approvals into the versioned Ad model, I’m back where I  
started with a set of approvals that don’t track the version.

Walter

---

<div class="post-metadata">

**Author:** ![walterdavis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a587f6/32.png) [@walterdavis](https://www.ruby-forum.com/u/walterdavis)\
**Post date:** [January 13, 2011, 10:20pm UTC](https://www.ruby-forum.com/t/vestal-versions-and-attr-accessors/201750/5 "2011-01-13T22:20:32Z")

</div>

Walter D. wrote in post #974750:

> On Jan 13, 2011, at 3:08 PM, Marnen Laibow-Koser wrote:
> 
> > > Versions to track changes to the value of these? I’m specifically  
> > > trying  
> > > to get these “synthetic” object properties to be stored in the  
> > > version  
> > > diff, along with the regular column-backed properties.
> > 
> > That sounds insane. If a property is worth tracking, isn’t it worth  
> > storing in the database?
> > 
> > Can you give an example of one of these properties?
> 
> Sure. I have an Approval, which is a sort of loosely-coupled join  
> model between a Role and an Ad. Ads are versioned, and each time I  
> make a new version of an Ad (to update the artwork or similar) I need  
> to store the current graph of approvals for historical purposes only.  
> (Who had approved it already, who hadn’t.)
> 
> I allow the users to step back through time to see the evolution of an  
> ad, and I need to show where it stood at each point. But changing the  
> approvals doesn’t update the version of an ad, only updating the  
> artwork does.

So do you need to show the user different Approvals for one version of  
an Ad?

> So I was thinking that I could record the current state  
> – as a snapshot – just before I saved the version and then play it  
> back whenever the version did not equal the last version.
> 
> Is there a simpler way to do this?

Almost certainly. You sound like you’re trying to add complexity when  
you could just be working through the object graph and associations.

> I have already wasted a lot of time  
> trying to version associated records in VV, and it’s made me very  
> cranky.

I don’t know if VV does association versions, but there are other gems  
that do – I seem to recall that acts\_as\_revisable is one.

> Walter

## Best,

Marnen Laibow-Koser

> **[marnen.org: Homepage of Marnen Laibow-Koser](https://marnen.org/)**

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
