如何更改设置到database.yml中的参数?例如:将param编码到datavase.yml是utf8,但我需要将其设置为等于utfmb4,但我无法更改database.yml文件。我该怎么做?可能与config.active_record一起进入config/application.rb文件。?
我们可以将database.yml更改为其他文件名。将其粘贴到第11行的config/application.rb中(在定义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
并将database.yml移动到config/database_actual.yml