使用mysql创建新项目导轨时找不到“ config / databases / mysql.yml”

时间:2018-09-24 15:40:14

标签: mysql ruby-on-rails ruby

有人可以帮助我吗?我想为Ruby on Rails创建新项目时遇到此错误

 ronggothelast  ~  belajar-rails  rails new kodooe -d mysql
  create  
  create  README.md
  create  Rakefile
  create  .ruby-version
  create  config.ru
  create  .gitignore
  create  Gemfile
  run  git init from "."
  Initialized empty Git repository in /home/ronggothelast/belajar-rails/kodooe/.git/
  create  package.json
  create  app
  create  app/assets/config/manifest.js
  create  app/assets/javascripts/application.js
  create  app/assets/javascripts/cable.js
  create  app/assets/stylesheets/application.css
  create  app/channels/application_cable/channel.rb
  create  app/channels/application_cable/connection.rb
  create  app/controllers/application_controller.rb
  create  app/helpers/application_helper.rb
  create  app/jobs/application_job.rb
  create  app/mailers/application_mailer.rb
  create  app/models/application_record.rb
  create  app/views/layouts/application.html.erb
  create  app/views/layouts/mailer.html.erb
  create  app/views/layouts/mailer.text.erb
  create  app/assets/images/.keep
  create  app/assets/javascripts/channels
  create  app/assets/javascripts/channels/.keep
  create  app/controllers/concerns/.keep
  create  app/models/concerns/.keep
  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake
  create  bin/setup
  create  bin/update
  create  bin/yarn
  create  config
  create  config/routes.rb
  create  config/application.rb
  create  config/environment.rb
  create  config/cable.yml
  create  config/puma.rb
  create  config/spring.rb
  create  config/storage.yml
  create  config/environments
  create  config/environments/development.rb
  create  config/environments/production.rb
  create  config/environments/test.rb
  create  config/initializers
  create  config/initializers/application_controller_renderer.rb
  create  config/initializers/assets.rb
  create  config/initializers/backtrace_silencers.rb
  create  config/initializers/content_security_policy.rb
  create  config/initializers/cookies_serializer.rb
  create  config/initializers/cors.rb
  create  config/initializers/filter_parameter_logging.rb
  create  config/initializers/inflections.rb
  create  config/initializers/mime_types.rb
  create  config/initializers/new_framework_defaults_5_2.rb
  create  config/initializers/wrap_parameters.rb
  create  config/locales
  create  config/locales/en.yml
  create  config/master.key
  append  .gitignore
  create  config/boot.rb
  

在您的任何来源中都找不到“ config / databases / mysql.yml”   路径。您当前的源路径是:   /home/ronggothelast/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/rails/app/templates

1 个答案:

答案 0 :(得分:0)

您似乎已使用命令删除系统上所有MySQL文件的命令,从模板文件夹中删除了mysql.yml.tt。
要解决这个问题: 1)在目录templates / config / databases /

中创建mysql.yml.tt文件
#include <stdio.h>
int main()
{
        int a, i, e = 0;
        int A[31];
        for (i = 0; i <= 30; i++) {
            scanf("%d", &a);
            A[i] = a;
        }

        for (i = 0; i < 30; i++){
            if (A[i] > 40 && A[i + 1] > 40)
                e = e + 1;
        }
        printf("%d", e);

        return 0;
}

2)使用vim粘贴original file from rails github中的基本代码,或从其源代码中打开文件并粘贴所有代码。

$ touch ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt

现在您可以使用$ vim ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt

重新制作项目