Single Table Inheritanceで親子関係にある二つのクラスHoge, Fugaがあるとする。 class Hoge < ActiveRecord::Base end class Fuga < Hoge end このときHogeクラスのオブジェクトaがあったとしてそれをFugaクラスに変換したいとする。 そもそもそういう状況がオブジェクト指向的にどうなのかというのは置いておく。 このとき、 a = Hoge.find(1) b = a.becomes(Fuga) b.save! とすればいいのかと思って試してみるも、ロードしなおしたオブジェクトはHogeクラスのままだった。 オブジェクトを保存するときのクエリーを見ると次のようになっていた。 UPDATE `hoges` SET `type` = 'Fuga', `updated_at` = '2013-04-08 14:0
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く