This is also posted at https://github.com/rails/rails/issues/16269 but I just wanted to get more peoples thoughts on if this is truly a bug or not.
In my migration I’m converting my
posts table to use uuids instead of the default integers via something like the following:
... create_table :posts_temp, id: :uuid do |t| t.string :title ... end post_temp_model = Class.new(ActiveRecord::Base) do self.table_name = :posts_temp end Post.all.each do |post| post_temp = post.dup.becomes(post_temp_model) binding.pry post_temp.name # => "foobar" post_temp.save # => true post_temp.reload post_temp.name # => nil end ...
When running this and inspecting what
post_temp.title is the value appears to be there. When calling
post_temp.reload and inspecting the
title again however it’s
nil. It seems as though the value is not being saved to the database.
Is this a bug or am I doing something incorrectly here?