如何更改设置为database.yml的params? 例如:编码param到datavase.yml是utf8但是我需要将它设置为utfmb4但我无法更改database.yml文件。我怎么能这样做? 可以使用config.active_record进入config / application.rb文件。?
答案 0 :(得分:0)
我们可以将database.yml更改为其他文件名。 将其粘贴到第11行的config / application.rb中(在定义捆绑器之后)
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