issue with capistrano-ext

5 views
Skip to first unread message

Alexey Zagarin

unread,
Jun 3, 2009, 7:51:40 AM6/3/09
to Capistrano
I have

set :default_stage, "development"
set :stages, %w(development production)
require 'capistrano/ext/multistage'

in my config/deploy.rb, and I have corresponding files in config/
deploy/ for each environment.

However, cap deploy:migrations sets RAILS_ENV=production when it runs
rake db:migrate.

Lee Hambley

unread,
Jun 3, 2009, 8:51:06 AM6/3/09
to capis...@googlegroups.com
Alexey,

That is the default behavior, you may have to try setting a variable called :migrate_env, and see what difference that makes, you may have to to set it with a lambda, something like this:

set(:migrate_env, { stage })

That should not err if stage isn't defined (something you may run into a few times with multistage) -- only evaluates the {} when the variable is accessed.

The actual task definition, is here in the code:


- Hope that helps

2009/6/3 Alexey Zagarin <zag...@gmail.com>

Simone Carletti

unread,
Jun 3, 2009, 8:57:57 AM6/3/09
to capis...@googlegroups.com
As far I remember, Multistage recipe doesn't automatically update your environment.
You need to set it manually.

# in config/deploy/production.rb
set :rails_env,     "production"

# in config/deploy/development.rb
set :rails_env,     "development"

You can also set it dynamically, loading the value from current stage.

set :rails_env, fetch(:stage)

However, the second option requires :stage to be set before the value is assigned to :rails_env.
You need to configure your deploy script or use a lambda to postpone code evaluation.

-- Simone
--
Simone Carletti

Site & Blog: http://www.simonecarletti.com
Email: wep...@weppos.net
LinkedIn: http://linkedin.com/in/weppos
Nick: weppos | Skype: weppos

Alexey Zagarin

unread,
Jun 3, 2009, 1:10:23 PM6/3/09
to Capistrano
Many thanks, now it works as expected!
Reply all
Reply to author
Forward
0 new messages