Last active
December 19, 2015 15:59
-
-
Save yusukeaiko/5980935 to your computer and use it in GitHub Desktop.
テーブル名からカラム情報を取得 ref: http://qiita.com/Vit-Symty/items/1f85707eedc07bb996c8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# テーブル名から、定義されているすべてのカラム定義を取得 | |
Module.const_get('users'.classify).columns | |
# 特定のカラムの情報を取得(例えば `id`) | |
Module.const_get('users'.classify).columns['id'] | |
# 特定のカラムから定義の一部を取得 | |
col = Module.const_get('users'.classify).columns['id'] | |
col.type # データ型を取得 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment