Last active
January 25, 2019 15:29
-
-
Save vochicong/0571567483777e26f6bad2ec425567c0 to your computer and use it in GitHub Desktop.
Rails credentials.yml.encと環境変数の併用 ref: https://qiita.com/vochicong/items/d384824f2952c46064ac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Env | |
def self.method_missing(name, *default) | |
ENV[name.to_s] || | |
default.first || | |
Rails.application.credentials.send(name) || | |
super | |
end | |
def self.respond_to_missing?(*) | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Env | |
def self.method_missing(name, *default) | |
ENV[name.to_s] || | |
default.first || | |
Rails.application.credentials.send(name) || | |
super | |
end | |
def self.respond_to_missing?(*) | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ RAILS_MASTER_KEY=289e1431050b365b62bb5917acabcc53 rails credentials:show | |
secret_key_base: 2105bc31227a27f81b901582a8bb43b35bebea2b9c3572b024184a0b06dad26fc3bb312fbc5a7069783798d22f55cf4f411ae19169dd2a78026dccfbbdc889d7 | |
APP_CONFIG: encryptedConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails runner 'puts Env.APP_CONFIG("default")' | |
default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ APP_CONFIG=envVar rails runner 'puts Env.APP_CONFIG("default")' | |
envVar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ RAILS_MASTER_KEY=289e1431050b365b62bb5917acabcc53 APP_CONFIG=envVar rails runner 'puts Env.APP_CONFIG("default")' | |
envVar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ RAILS_MASTER_KEY=289e1431050b365b62bb5917acabcc53 rails runner 'puts Env.APP_CONFIG("default")' | |
default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ RAILS_MASTER_KEY=289e1431050b365b62bb5917acabcc53 rails runner 'puts Env.APP_CONFIG' | |
encryptedConfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment