Hi all,
I’ve hit something migrating from rails 2.0.2 to 2.2.2 and I’m wondering if it’s a bug or if there’s something I’m not aware of coming into play. I’ve abstracted the problem a little bit but it still reproduces with the abstracted example.
I’ve got a model called multi_save.
class CreateMultiSaves < ActiveRecord::Migration
def self.up create_table :multi_saves do |t| t.integer :id_dependant t.string :name t.string :name_dependant t.timestamps end end
def self.down drop_table :multi_saves
end end
class MultiSave < ActiveRecord::Base def id=(value)
write_attribute :id, value write_attribute :id_dependant, value*5 end def name=(value) write_attribute :name, value write_attribute :name_dependant, value + " rocks" end
end
I’ve got a controller looking like:
class MultiSaveController < ApplicationController def create @object = MultiSave.new end
def new @multi_save = MultiSave.new(params[:multi_save]) @multi_save.save! # saves properly @multi_save.save! # doesn't do anything end3
end
With this code in rails 2.0.2 the second call to save! sends an update statement to the database. In 2.2.2 the second call to save! issues no call to the database. After the first call to save the id_dependant fields gets properly as I would expect in both 2.0.2 and 2.2.2.