using RAILS_RELATIVE_URL_ROOT for assets:precompile in Capistrano 3 ?

253 views
Skip to first unread message

Marvin Frederickson

unread,
Dec 31, 2013, 11:56:16 PM12/31/13
to capis...@googlegroups.com
In capistrano 2 I could specify this in my deploy.rb and my assets would be precompiled properly (my app is deployed under a sub-uri)
  set :asset_env, "#{asset_env} RAILS_RELATIVE_URL_ROOT=/#{application}"

in capistrano 3 how do I do this?  The below does not seem to work... it never gets passed to the rake task like it did in cap 2.
  set :asset_env, "#{fetch(:asset_env)} RAILS_RELATIVE_URL_ROOT=/#{fetch(:application)}"


I saw this article http://www.capistranorb.com/2013/06/01/release-announcement.html that shows that the stuff in cap2 like this
# Capistrano 2.0.x
task :precompile, :roles => lambda { assets_role }, :except => { :no_release => true } do
  run <<-CMD.compact
    cd -- #{latest_release} &&
    RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} #{rake} assets:precompile
  CMD
end
is now like this in cap 3
# Capistrano 3.0.x
task :precompile do
  on :sprockets_asset_host, reject: lambda { |h| h.properties.no_release } do
    within fetch(:latest_release_directory)
      with rails_env: fetch(:rails_env) do
        execute :rake, 'assets:precompile'
      end
    end
  end
end
which as you can see, the execute :rake doesn't seem to include the asset_env like it did in cap 2.... ????


Lee Hambley

unread,
Jan 1, 2014, 12:26:12 PM1/1/14
to capistrano
I can't see the words `asset_env` in your Cap3 example? You might try:

    with asset_env.merge(rails_env: fetch(:rails_env)) do { .... }

Assuming asset_env is a hash, in any case with() expects a hash.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/50a2d545-8c99-408c-a271-66a3ca107dbd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages