Coder Social home page Coder Social logo

Comments (6)

tsechingho avatar tsechingho commented on May 31, 2024

你可以試試 https://github.com/bkeepers/dotenv

另外要看 production 主機的 deploy 方式

  • heroku 是在指令定義 ENV 變數
  • capistrano 的話,是在 receipt 內定義 ENV 變數

ENV['DATABASE_PASSWORD'] 應該是存在每個 shell 中的,才有基本安全可言。
若你設定 ENV 在 ~/.bashrc 或 /etc/bashrc 的話,比較不適合有 password 等資料

from ama.

bugtender avatar bugtender commented on May 31, 2024

你可以試試看 Figaro
要自行定義ENV的話,這個很方便

from ama.

CarolHsu avatar CarolHsu commented on May 31, 2024

Figaro +1

from ama.

adlerhsieh avatar adlerhsieh commented on May 31, 2024

我試過幾個方法,Figaro + 1,可加入.gitignore以免敏感資料曝光。我個人比較不喜歡用ENV這個變數,比較不敏感的資料會丟到config/initializers資料夾底下另外開一個檔案,裡面用一個class包起來,用起來還算順手,例如:

module Business
  class Logic
    Here = "hello world"
  end
end

# 在app任何地方使用
Business::Logic::Here
# => "hello world"

from ama.

JuanitoFatas avatar JuanitoFatas commented on May 31, 2024

@afgnsu 上面的回答有解決你的問題了嗎?😊

from ama.

afgnsu avatar afgnsu commented on May 31, 2024

Very Good,謝謝大家 ^_^

from ama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.