小编rub*_*vel的帖子

ENV ["RAILS_MASTER_KEY"] 适用于 master.key,但是 Rails 将检查development.key 或 production.key 的环境变量

我一直在尝试将我的 Rails 凭证密钥放入环境变量中。Rails 指南说:

Rails 使用 config/master.key 或者查找环境变量“RAILS_MASTER_KEY”来加密凭证文件。

我正在运行 Rails 7,并且每个 Rails 环境都有不同的凭据文件,即

配置/凭据/

development.yml.enc
development.key
production.yml.enc
production.key
Run Code Online (Sandbox Code Playgroud)

所以它说我可以使用“RAILS_MASTER_KEY”]来覆盖这些.key文件中的任何一个。例如,我试图找出一种使用“RAILS_DEV_KEY”等环境变量来代替development.key的方法。

当我运行这个时:

Rails.application.credentials

我明白了:

Rails.application.credentials 输出

有没有办法将上面的“@env_key”变量更改为“RAILS_DEV_KEY”

security ruby-on-rails credentials environment-variables

6
推荐指数
0
解决办法
2280
查看次数

Rspec.describe上的单位化常量Rspec(名称错误)

当我运行我的测试时,我收到此错误:

top (required) : uninitialized constant Rspec (NameError)
Run Code Online (Sandbox Code Playgroud)

这是模型测试失败,除非我删除'Rspec'.

ROOT_APP /规格/型号/文件/ date_spec.rb:

require 'rails_helper'

Rspec.describe Document::Date, :type => :model do
  pending "add some examples to (or delete) #{__FILE__}"
end
Run Code Online (Sandbox Code Playgroud)

我知道最好使用Rspec.describe而不是describe.(关于猴子修补的东西,不确定这是什么).

当然我可以单独使用describe,这就是我现在正在做的只是让我的测试工作.我只想更多地了解可能发生的事情.

全部在ROOT_APP/spec目录下:

rails_helper.rb

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'spec_helper'

require 'factory_girl'
require 'capybara/rspec'
require 'capybara/rails'

  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

RSpec.configure do |config|

  config.infer_spec_type_from_file_location!

  config.include(MailerMacros)
  config.before(:each) { reset_email }

  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true
  config.include FactoryGirl::Syntax::Methods
end
Run Code Online (Sandbox Code Playgroud)

spec_helper.rb

RSpec.configure do |config|

config.expect_with :rspec …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails

2
推荐指数
1
解决办法
138
查看次数