PG::Error: ERROR: new encoding (UTF8) is incompatible

后端 未结 6 1247
迷失自我
迷失自我 2021-01-29 19:16

I have installed postgresql-9.2.4 from the source, now in rails app when I execute:

rake db:create command I get:

$ bin/rake db         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-01-29 19:18

    I had a similar issue. My database.yml was like this:-

    default: &default
      adapter: postgresql
      encoding: unicode
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
    
    development:
      <<: *default
      database: chatapp_development
    
    test:
      <<: *default
      database: chatapp_test
    
    production:
      <<: *default
      database: chatapp_production
      username: chatapp
      password: <%= ENV['CHATAPP_DATABASE_PASSWORD'] %>
    

    I added template: template0 to the default settings

    default: &default
      adapter: postgresql
      template: template0
      encoding: unicode
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
    

    And it worked

提交回复
热议问题