Rails 6 Credentials (master.key and credentials.yml.enc)
Tag: Ruby
Tag: Rails
Category: jekyll
Category: update
Category: git
Category: database
Category: PostgreSQL
Category: websocket
Category: ruby
Category: projects
Category: Redis
Category: mysql
Category: Mac
Category: Node
Category: NPM
Category: PM2
Category: nodejs
Category: Meteor
Category: Nginx
Category: gitLab
Category: Rails
- Why Ruby on Rails is better than Python Django?
- How to use Hotwire turbo in Rails 6 with Webpacker?
- Rails 6 Credentials (master.key and credentials.yml.enc)
- Rails Console
- JIRA-Atlassian-Connect-App-Django
- Rails 4 5.0 Session Cookie AuthenticityToken
- Rails Active Storage
- Rails 5 Source code Research
- 微信支付
- Rails零星笔记
Category: Homebrew
Category: CentOS
Category: FreeSwitch
Category: Ruby
- Ruby on Rails 8
- RESTful API
- Ruby on Rails 7
- Study from Ruby official website
- Ruby-Metaprogramming
- Ruby连数据库的问题
- rbenv使用
Category: Vim
Category: javascript
Category: React-Native
Category: Wechat
Category: homeland
Category: JavaScript
Category: Docker
Category: RubyMine
Category: Authorization
Category: RESTful-API
Category: Proxy
Category: Deploy
Category: Devise
Category: Bootstrap
Category: Active_Storage
Category: github
Category: Android
Category: cloud
Category: ssh
Category: python
Category: reactjs
Category: markdown
Category: ShadowSocks
Category: Code
Category: rails
Category: code
Category: Django
Category: Python
Category: DRF
Category: Fish
Category: Yarn
Category: Material-UI
Category: CSS
Category: aws
Category: uwsgi
Category: nginx
Category: docker
Category: React
Category: Enzyme
Category: Jira
Category: Interview
Category: JetBrain
Category: PyCharm
Category: ESLint
Category: Rails6
Category: NVM
Category: ssl
Category: tencent
Category: CI
Category: jenkins
Category: GitHub
Category: Credentials
Category: master.key
Category: Webpacker
Category: Turbo
Category: Hotwire
Category: Bootstrap5
Category: Flutter
Category: Clash
Category: Tor
Category: proxy
Category: Build
Category: SwitchyOmega
Category: Chrome-extension
Category: SQLAlchemy
Category: Algorithm
Category: Rails7
Category: Data
Category: Structure
Category: CPP
Category: Languages
Category: Golang
Category: Typescript
Category: Rails 8
You can start with https://blog.saeloun.com/2019/10/10/rails-6-adds-support-for-multi-environment-credentials.html
and https://github.com/rails/rails/issues/30006
For test
and development
env, you can simply remove the master.key
and you will find that rails s
works well.
You can run rails console
, then run Rails.application.credentials.config
to see that the value.
But if you have a wrong master.key
there and run rails s
, you will get an error.
But if you removed master.key
, you will find that rails s -e production
doesn’t work.
If you have the correct value of master.key
, you can run EDITOR=vim rails credentials:edit
to edit it.
If you don’t have the correct value of master.key
, when you run EDITOR=vim rails credentials:edit
,
it will generate a new master.key
for you but unfortunately that master.key
is a wrong one.
This is reasonable because it makes the credentials.yml.enc
unable to be decrypt unless you have already got a correct master.key
.
So you can remove the credentials.yml.enc
and master.key
and run EDITOR=vim rails credentials:edit
to generate a new pair.
But before you do that, you should remove master.key
and run rails console
, then run Rails.application.credentials.config
to
understand what values you need to set when running EDITOR=vim rails credentials:edit
.
All the Rails instance in production
env should have the same credentials.yml.enc
and master.key
.
So you should keep credentials.yml.enc
in your sources code.