# Version\_fu and text fields

**URL:** <https://www.ruby-forum.com/t/version-fu-and-text-fields/152233>\
**Category:** Rails\
**Created:** [October 31, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/version-fu-and-text-fields/152233 "2008-10-31T16:45:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tansaku](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tansaku](https://www.ruby-forum.com/u/tansaku)\
**Post date:** [October 31, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/version-fu-and-text-fields/152233/1 "2008-10-31T16:45:46Z")

</div>

I’m having trouble with version\_fu and text fields. I’m posting to  
the version\_fu wiki:

> **[Pages · jmckible/version\_fu Wiki](https://github.com/jmckible/version_fu/wiki/)**
>
> Rails 3 update of acts\_as\_versioned. Contribute to jmckible/version\_fu development by creating an account on GitHub.

but here as well in case anyone can help - or can later benefit from  
the cross-linking if we solve the problem:

Issue 2: wrong values for text/blob moved over to versioned table

the text field in the table created by the following:

def self.up  
create\_table :statistic\_type\_versions do |t|  
t.integer :statistic\_type\_id, :statistic\_category\_id  
t.string :name, :time\_filter, :unit  
t.text :sql  
t.timestamps  
end  
add\_column :statistic\_types, :version, :integer, :default=\>1  
end

appears to have the data from the new version rather than the old  
version in it. The old data appears to be lost, or as in the case  
below the text/blob field may also just be nil.

> > type = StatisticType.new  
> > =\> #\<StatisticType id: nil, name: “”, time\_filter: “”, unit: “”, sql:  
> > nil, statistic\_category\_id: nil, version: 1\>  
> > type.name = ‘original\_name’  
> > =\> “original\_name”  
> > type.sql = ‘original\_sql’  
> > =\> “original\_sql”  
> > type.save  
> > =\> true  
> > type.name  
> > =\> “original\_name”  
> > type.sql  
> > =\> “original\_sql”  
> > type.name = ‘new\_name’  
> > =\> “new\_name”  
> > type.sql = ‘new\_sql’  
> > =\> “new\_sql”  
> > type.save  
> > =\> true  
> > type.name  
> > =\> “new\_name”  
> > type.sql  
> > =\> “new\_sql”  
> > type.id  
> > =\> 5  
> > versioned\_type = StatisticType::Version.find(:first, :conditions =\> ‘statistic\_type\_id = 5’)  
> > =\> #\<StatisticType::Version id: 7, statistic\_type\_id: 5,  
> > statistic\_category\_id: nil, version: 1, name: “original\_name”,  
> > time\_filter: “”, unit: “”, sql: nil, created\_at: “2008-10-31  
> > 15:34:15”, updated\_at: “2008-10-31 15:34:15”\>  
> > versioned\_type.name  
> > =\> “original\_name”  
> > versioned\_type.sql  
> > =\> nil

any ideas?

Many thanks in advance  
CHEERS\> SAM
