Version_fu and text fields

I’m having trouble with version_fu and text fields. I’m posting to
the version_fu wiki:

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
add_column :statistic_types, :version, :integer, :default=>1

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 id: nil, name: “”, time_filter: “”, unit: “”, sql:
nil, statistic_category_id: nil, version: 1> = ‘original_name’
=> “original_name”

type.sql = ‘original_sql’
=> “original_sql”
=> true
=> “original_name”

=> “original_sql” = ‘new_name’
=> “new_name”

type.sql = ‘new_sql’
=> “new_sql”
=> true
=> “new_name”

=> “new_sql”
=> 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”>
=> “original_name”

=> nil

any ideas?

Many thanks in advance

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