# Acts\_as\_versioned and parent model methods

**URL:** <https://www.ruby-forum.com/t/acts-as-versioned-and-parent-model-methods/119651>\
**Category:** Rails\
**Created:** [November 8, 2007, 9:57pm UTC](https://www.ruby-forum.com/t/acts-as-versioned-and-parent-model-methods/119651 "2007-11-08T21:57:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [November 8, 2007, 9:57pm UTC](https://www.ruby-forum.com/t/acts-as-versioned-and-parent-model-methods/119651/1 "2007-11-08T21:57:16Z")

</div>

I am trying to iterate through the versions of my Day model in a view,  
and want to apply some model methods to it. Here’s an example:

\<% day.versions.reject!{ |v| v.version == 1 }.each do |d| -\>  
\<= d.process\_date\_this\_version \>  
\< end %\>

I get a “undefined method `process\_date\_this\_version’ for  
#day::version:0x33b44f0” error. If I run it against d.day, things  
run fine, but that’s querying the latest revision, which isn’t  
desirable. What would be the preferred way to iterate through the  
versions, and run models from my Day model on the Day::Version models?

Any help would be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [November 9, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/acts-as-versioned-and-parent-model-methods/119651/2 "2007-11-09T15:30:58Z")

</div>

On Nov 8, 2007 12:56 PM, Justin W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> run fine, but that’s querying the latest revision, which isn’t  
> desirable. What would be the preferred way to iterate through the  
> versions, and run models from my Day model on the Day::Version models?
> 
> Any help would be appreciated.

acts\_as\_versioned supports extensions like associations, so you can  
define behavior on both models. This is actually my favorite feature,  
and it’s why aav is written the way it is (vs using some diffing  
algorithm or storing all versions for all models in a single table)

acts\_as\_versioned do  
def process\_date\_this\_version  
end  
end

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
