Acts_as_versioned only for certain fields?

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.

On 1/23/07, Carl J. [email protected] 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://mephistoblog.com

On 1/24/07, Carl J. [email protected] 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://mephistoblog.com

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!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs