Reputation: 3699
I'm deploying my application using capistrano for two different servers of production mode, but I need to vary some contents in production.rb
for each server.
2 Possible ways I know.
I feel both are little heavy for a couple of lines change.
Using different branch(git) for each. - Worried about maintenance.
Creating a different environment.
How to deal with this situation, a simpler one choose from or new a way?
Rails 3 and Cap 2
Edit: I was also suggested to Use ENV variables or include a file elsewhere on the server
Upvotes: 3
Views: 417
Reputation: 35483
Using different branch(git) for each.
Do it this way if and only if:
You want each of the server apps to have markedly different features, and the features interfere with each other i.e. there is no easy way to use a server-specific feature flag.
For example, if one server is an alpha-test for new code, and one server is a beta-test for new code.
Creating a different environment.
Do it this way if and only if:
You want each of the server apps to have markedly different experiences.
For example, if one server is a demonstration server for trade shows and thus gets wiped often, and one server is your real site for customers.
Use ENV variables
This is the best way.
Use the dotenv gem or similar figaro gem.
"dotenv solves the problems of setting project-specific environment vars and is super easy to get started on. Start by including the gem 'dotenv-rails', :groups => [:development, :test] in the appropriate groups, in this case development and test. You can then put your sensitive information inside a .env file at the root of your project directory"
"Figaro is similar to dotenv. What it does is to allow you to store all your sensitive secrets in a YAML file at config/application.yml. With it’s simple figaro install command you get your YAML file automatically added to gitignore. Figaro is built with deployment to Heroku in mind. There is a handy configuration to help set values from your configuration file. It also provides helpful information on deploying to other hosts."
Credit: Managing Environment Configuration in Rails
Upvotes: 1