We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Francisco Quintero • 9 years ago

Cool post. It is very important to keep staging in a separate server. Having it in the same server as production, additional to what you say, is a pain in the ass to setup both environments in the same machine.

It is way better to have a VPS for staging and a separate one for production.

Thank you for sharing, I'm bookmarking this.

wdiechmann • 9 years ago

still a great post!

but on a tangential note, my config/unicorn_init.sh really had me bugged down - here's why:

~/.rbenv/bin/rbenv exec bundle exec unicorn -D -c $APP_ROOT/config/$UNICORN -E staging

should think that would kick some 'staging tyres', but alas it spun wheels on my production! After a very sleepless night, I finally tried adding RAILS_ENV=demo to the mix - and lo' and behold: now my demo-site was up and running

now this observation sits here with you in case other (n00bs like me) misinterprets the -E for taking precedence over the ENV variable ;)

Borja G. Vinuesa • 10 years ago

Thanks! Very good post.

What do you think about the recommendation Heroku gives?

"Copying production data to test apps means risk of data leaks or other programming mistakes operating on recent customer data. For those reasons, we instead recommend seeding databases comprehensively with non-production data using seed scripts run with the postdeploy command."

More on https://devcenter.heroku.co...

João Marcelo • 10 years ago

Great post! Note: fix the double quotes in the sample for lib/tasks/dump.rake

# Styled quotes will break:
raise "Need a REMOTE file” unless remote
# Quotes must be unstyled:
raise "Need a REMOTE file" unless remote

Maxime Garcia • 10 years ago

Good catch! Thanks :)

Anthony Ilinykh • 10 years ago

Thanks! Very useful!

Andreas Lyngstad • 11 years ago

Great post! Thanks!

Andrey Morskov • 11 years ago

For stages you could try http://teatro.io, which performs parallel stages for every feature branch. It's easy!

Kyle • 11 years ago

OMG...thank you for this! I've been trying to figure out how to do this for weeks! I haven't had a chance to read the whole thing yet, but so far, it looks exactly like what I need. :)

Also, related: would most of the same steps be necessary to create a subdomain like, say, beta.website.com, to have a totally different layout for the site, but still in production? So like, I have my regular site and then a totally new/different layout to experiment with and allow uses to play with that still feeds into/from the production database?

Maxime Garcia • 11 years ago

Thanks!

You want to have a new view path in your application. You can create a "app/views/beta" directory, and put your views as if you were in "app/views".

In your ApplicationController, in a before_filter, have your logic do a prepend_view_path "app/views/beta".
Something like:


before_filter :setup_beta

def setup_beta
if request.subdomain == "beta"
prepend_view_path "app/views/beta"
# other beta setup
end
end

This way, templates are resolved in "app/views/beta" first, and then, if not found, in "app/views". Note that, you only have to put in "app/views/beta" the views that differ from those in "app/views".

I let you elaborate around this.

Kyle • 11 years ago

Thank you so much for this. I'm sorry I haven't thank you sooner...finally started implementing this tonight and the beta subdomain works BRILLIANTLY.