关于this question,我试图覆盖返回PostgreSQL版本的postgresql_version
中定义的ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
方法:
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
protected
# Returns the version of the connected PostgreSQL server.
def postgresql_version
80200
end
end
end
end
但修补程序未应用。我尝试在config / initializer中并在/ lib文件中要求它。帮助
答案 0 :(得分:7)
试试这个:
# ensure ActiveRecord's version has been required already
require 'active_record/connection_adapters/postgresql_adapter'
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
protected
def postgresql_version
80200
end
end
你的解决方案失败了,因为在修补猴子时你不能添加继承部分(即PostgreSQLAdapter < AbstractAdapter
)