How to disable prepared statement in heroku with postgres database

后端 未结 6 1108
-上瘾入骨i
-上瘾入骨i 2021-02-20 12:13

I fixed an issue on my rails project locally (with postgres config) while adding in database.yml this statement:

test:
  prepared_statements: false
6条回答
  •  不要未来只要你来
    2021-02-20 12:35

    You can pass in a configuration hash to ActiveRecord::Base.establish_connection, in an initializer. For example:

    configure :production, :development, :test do
      db = URI.parse(ENV['DATABASE_URL']
    
      ActiveRecord::Base.establish_connection(
          :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
          :host                => db.host,
          :username            => db.user,
          :password            => db.password,
          :database            => db.path[1..-1],
          :encoding            => 'utf8',
          :prepared_statements => false,
      )
    end
    

    http://apidock.com/rails/ActiveRecord/Base/establish_connection/class

提交回复
热议问题