简体   繁体   English

尝试在 mac 上运行 rails 应用程序时出错

[英]Error when trying to run rails application on mac

I'm am working as a part of a team for a school project.我正在作为学校项目团队的一部分工作。 We are using Ruby 2.6.5 and Rails 6.0.2.1.我们使用 Ruby 2.6.5 和 Rails 6.0.2.1。 I have pulled the master branch from GitHub, but when I try to run the application I get this error:我已经从 GitHub 中提取了 master 分支,但是当我尝试运行该应用程序时,我收到此错误:

ArgumentError: Missing secret_key_base for 'production' environment ArgumentError:“生产”环境缺少secret_key_base

I have looked online and found that the old solution was to change the config/secrets.yml file, but rails 6 no longer has that file, and instead has an encoded credentials.yml.enc file that has the same functionality.我在网上查看,发现旧的解决方案是更改 config/secrets.yml 文件,但 rails 6 不再有该文件,而是有一个具有相同功能的编码凭据.yml.enc 文件。 How do I fix this issue?我该如何解决这个问题?

You can try changing the config.require_master_key = true #in config/environments/production.rb您可以尝试更改config.require_master_key = true #in config/environments/production.rb

You can go to this link to check this in detail:- https://blog.engineyard.com/rails-encrypted-credentials-on-rails-5.2您可以转到此链接详细查看:- https://blog.engineyard.com/rails-encrypted-credentials-on-rails-5.2

I hope this will work for you.我希望这对你有用。

Rails > 5.2 introduced a new feature for securing credentials. Rails > 5.2 引入了保护凭据的新功能。 For this rails uses a master.key in config folder which is usually added to .gitignore so that it stays secure and doesn't get pushed to git.为此,rails 使用config文件夹中的master.key该文件夹通常被添加到.gitignore中,以保持安全并且不会被推送到 git。

This master.key is used to encrypt or decrypt content from the credentials.yml.enc file which you found.master.key用于加密或解密您找到的credentials.yml.enc文件中的内容。

If you are working on a team then the project creator will have to share this master.key file to you personally or you have to create a new credentials.yml.enc .如果您在团队中工作,则项目创建者必须亲自与您共享此master.key文件,否则您必须创建一个新的credentials.yml.enc You can do it using the below command -您可以使用以下命令来完成 -

EDITOR=vim rails credentials:edit

This will create a new master.key and credentials.yml.enc in your machine but the changes made by your teammates in the credentials.yml.enc will be lost.这将在您的机器中创建一个新的master.keycredentials.yml.enc ,但您的队友在credentials.yml.enc所做的更改将丢失。 To avoid that hassle just get the master.key from your teammate and put it in the config .为了避免这种麻烦,只需从您的队友那里获取master.key并将其放入config folder.文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM