Categories
open all | close allTags
Subversion | Aptana | rake | JustPosted | Flash | CSRF | rubygems | 名称 | 国際化 | パソコン | RESTful | カテゴリ | タグ | 認証 | フォーム | スキンエンジン | Migration | デュアル・コア | ドキュメント | テストSearch
作業メモ
まだリレーションのテストは確認していないけど一応テストは動くようになったので,ここまでの作業メモ。まずはプリフィクスを付けるプラグインは以下のようにして,environment.rbの中でset_prefixでプレフィクスを設定。
# Prefixed
module ActiveRecord
class Base
class <<Base
alias :original_table_name :table_name
def set_base_name(basename)
@base_name = basename
end
def set_prefix(prefix)
@@nucleus_prefix = prefix
end
def table_name
if @base_name
@@nucleus_prefix + @base_name.to_s
else
original_table_name
end
end
end
end
end
後は,各クラスではset_base_nameでベースネームを設定(これってアクセサにすべきだった? ちょっとかっこ悪いけどまあいいや)。
テストの方は モデルクラス_test.rb の中でfixtureとしてプリフィクス付きのテーブル名を指定。あわせてfixturesの中のYAMLのファイル名もテーブル名と同じものに変更。さらにYAMLの中でidとなっているところは,実際のID(inumberなど)に修正。
今日はここまで(受験の神様風,笑)
Comments
No comments yet. You can be the first!