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