<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: capistrano code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 09:41:01 GMT</pubDate>
    <description>DZone Snippets: capistrano code</description>
    <item>
      <title>Rails Environment Specific Capistrano Includes/Overrides</title>
      <link>http://snippets.dzone.com/posts/show/4950</link>
      <description>This cap technique allows you to include environment specific tasks and namespaces as well as override anything in the master deploy.rb. Its rather simplistic.&lt;br /&gt;&lt;br /&gt;Add your environment specific cap scripts into RAILS_ROOT/config/deployments/.&lt;br /&gt;&lt;br /&gt;Example command-line usage:&lt;br /&gt;&lt;br /&gt;# RAILS_ENV=production cap deploy&lt;br /&gt;&lt;br /&gt;...or...&lt;br /&gt;&lt;br /&gt;# cap deploy rails_env=beta&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Example needed variables at the top of your deploy.rb&lt;br /&gt;&lt;br /&gt;set :default_env,  'beta'&lt;br /&gt;set :rails_env,     ENV['rails_env'] || ENV['RAILS_ENV'] || default_env&lt;br /&gt;set :extra_deploys, 'config/deployments/'&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;# Now add this to the bottom of your deploy.rb, last thing to load.&lt;br /&gt;&lt;br /&gt;if extra_deploys &amp;&amp; File.exists?(extra_deploys+rails_env+".rb")&lt;br /&gt;  puts "Loaded #{extra_deploys+rails_env}.rb" if load extra_deploys+rails_env&lt;br /&gt;else&lt;br /&gt;  puts "Could not find #{extra_deploys+rails_env}.rb"&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You may change your default_env or any other piece to fit into your deployments. The secret is "load" method call burried in that latter code portion above. The reason you load at the end of your deploy.rb is so you can override anything defined above that call in your environment specific scripts.</description>
      <pubDate>Sat, 05 Jan 2008 19:21:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4950</guid>
      <author>justinwr (Justin R)</author>
    </item>
  </channel>
</rss>
