human_attribute_name
日本語にしてみたくてMySQLに突っ込んだコメントを取得するようにしてみたのだけど。。。
こんな感じで。
module ActiveRecord module ConnectionAdapters class MysqlColumn attr_reader :name, :default, :type, :limit, :null, :comment def initialize(name, default, sql_type = nil, null = true, comment = nil) @name, @type, @null, @comment = name, simplified_type(sql_type), null, comment # have to do this one separately because type_cast depends on #type @default = type_cast(default) @limit = extract_limit(sql_type) unless sql_type.nil? @primary = nil @text = [:string, :text].include? @type @number = [:float, :integer].include? @type end end class MysqlAdapter def columns(table_name, name = nil)#:nodoc: sql = "SHOW FULL FIELDS FROM #{table_name}" columns = [] execute(sql, name).each { |field| columns << MysqlColumn.new(field[0], field[5], field[1], field[3] == "YES", field[8]) } columns end end end end
Rubyよくわかってないのでinitializeはほぼそのままコピペ。
とりあえず動くっぽいけど、何か微妙。