跳至内容 跳至搜索
命名空间
方法
R

类公共方法

register(name, class_name, path = class_name.underscore)

注册自定义数据库适配器。

也可以用来定义别名。

示例

ActiveRecord::ConnectionAdapters.register("megadb", "MegaDB::ActiveRecordAdapter", "mega_db/active_record_adapter")

ActiveRecord::ConnectionAdapters.register("mysql", "ActiveRecord::ConnectionAdapters::TrilogyAdapter", "active_record/connection_adapters/trilogy_adapter")
# File activerecord/lib/active_record/connection_adapters.rb, line 22
def register(name, class_name, path = class_name.underscore)
  @adapters[name.to_s] = [class_name, path]
end