Skip to content

Instantly share code, notes, and snippets.

@todesking
Created August 27, 2012 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todesking/3485774 to your computer and use it in GitHub Desktop.
Save todesking/3485774 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# まだテーブル構造がちゃんと決まってないので、データをコード内にベタ書きしてある。
# 将来的にはActiveRecord化してDBに保存したい。
class NewModel
def self.find(id)
INSTANCES[id] || (raise "not found")
end
INSTANCES = {
1 => new(1, :hoge),
}
end
# このクライアントコードは、NewModelの実装が変わっても修正する必要がないとうれしい
class OtherModel < ActiveRecord::Base
belongs_to :new_model
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment