You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
serialize-rails gemでJSONをDBに格納するという記事を書いたけど、わざわざgemを使わなくても第2引数に渡すオブジェクトがloadとdumpを実装していれば十分だった。ちなみにActiveRecord 3.2で確認。 たとえばURLをURIのオブジェクトとして扱いたい場合。 # app/models/uri_coder.rb class UriCoder # ActiveRecord::Baseのインスタンスが作られるときに呼ばれる。 # DBから読み出したときにはstringには保存されている値が渡され、 # newされたときにはnilが渡される。 def load(string) URI.parse(string) if string.present? end # DBに書き込むときに呼ばれる。 def dump(uri) uri.to_s end end # a
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く