Categories
open all | close allTags
デュアル・コア | モデル | パソコン | RESTful | rake | Flash | Migration | タグ | JustPosted | CSRF | フォーム | テスト | Aptana | スキンエンジン | 名称 | 認証 | ドキュメント | Subversion | アクセス制御 | 国際化Search
うまくいった
ライブラリを呼び出すための$LOAD_PATHに対してクラス名+migrationのディレクトリがあるかどうかを調べていくことで問題解決(多分)。コードはこんな感じ。
def schema_version
match = Regexp.new('^(\d{3,})_(.*)\.rb$')
max = 0
$LOAD_PATH.each do |load_path|
path = load_path + '/' + name.underscore + '/migration'
begin
Dir.foreach(path) do |fname|
if fname =~ match
version = $1.to_i
max = version if version > max
end
end
return max
rescue
end
end
return 0
endComments
No comments yet. You can be the first!