← Back to Upcase

Set encoding database connections


(Boris Kuznetsov) #1

Hi, I use AWS Opswork and its great service. It use chef for start and configure a new instance but I have a trouble.
Opswork create database.yml file with utf8 encoding parametr and its bad because right encoding for mysql is utfmb4 (for example utf8 not support Emoji smiles).
I send pull request for fix it https://github.com/aws/opsworks-cookbooks/pull/56/files but it not merged yet.

Question:
How I can set encoding param into my rails application? Into config or may be into models. Any ideas?


(Boris Kuznetsov) #2

We can change database.yml to other filename.
Paste it Into config/application.rb on line 11 (after define bundler)

module Rails
  class Application
    class Configuration < ::Rails::Engine::Configuration
      def paths
        @paths ||= begin
          paths = super
          paths.add "config/database",    with: "config/database_actual.yml"
          paths.add "config/environment", with: "config/environment.rb"
          paths.add "lib/templates"
          paths.add "log",                with: "log/#{Rails.env}.log"
          paths.add "public"
          paths.add "public/javascripts"
          paths.add "public/stylesheets"
          paths.add "tmp"
          paths
        end
      end
    end
  end
end

And move database.yml to config/database_actual.yml