# Acts\_as\_versioned only for certain fields?

**URL:** <https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183>\
**Category:** Rails\
**Created:** [January 24, 2007, 6:11am UTC](https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183 "2007-01-24T06:11:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 24, 2007, 6:11am UTC](https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183/1 "2007-01-24T06:11:59Z")

</div>

acts\_as\_versioned is a GREAT plugin. Having trouble only versioning  
specific fields however. Most of my fields will never change so it is a  
waste to store the same data over and over in all the versions. The docs  
say “the \_versions table should contain all the fields you want  
versioned”. I’ve done that – the fields that I don’t want versioned are  
not in the \_versions table. I get an error when I try to save though.  
Any ideas?

Example:

class Picture \< ActiveRecord::Base  
belongs\_to :style  
acts\_as\_versioned  
end

@picture = Picture.find(1)  
@picture.caption = ‘A new caption that should be in a new version.’  
@picture.save

Then I get: NoMethodError: undefined method `style\_id=’ for  
#Picture::Version:0x3109e58

style\_id will never change though (or I don’t care if its changes are  
versioned) so I did not include it in the picture\_versions table.

Thanks very much.

---

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 24, 2007, 6:16am UTC](https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183/2 "2007-01-24T06:16:29Z")

</div>

On 1/23/07, Carl J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #Picture::Version:0x3109e58
> 
> style\_id will never change though (or I don’t care if its changes are  
> versioned) so I did not include it in the picture\_versions table.
> 
> Thanks very much.

class Picture \< AR::Base  
acts\_as\_versioned  
non\_versioned\_columns \<\< ‘style\_id’  
end

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

---

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 24, 2007, 7:20am UTC](https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183/3 "2007-01-24T07:20:34Z")

</div>

On 1/24/07, Carl J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > class Picture \< AR::Base  
> > acts\_as\_versioned  
> > non\_versioned\_columns \<\< ‘style\_id’  
> > end
> 
> Ahh, I see! I saw that referenced on the rails wiki but it was unclear.  
> Thanks!!

in your rails app directory type:

$ rake doc:plugins

Then open doc/plugins/acts\_as\_versioned/index.html in your browser.

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

---

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 24, 2007, 7:05am UTC](https://www.ruby-forum.com/t/acts-as-versioned-only-for-certain-fields/83183/4 "2007-01-24T07:05:25Z")

</div>

> class Picture \< AR::Base  
> acts\_as\_versioned  
> non\_versioned\_columns \<\< ‘style\_id’  
> end

Ahh, I see! I saw that referenced on the rails wiki but it was unclear.  
Thanks!!
