<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lasse Bunk&#039;s weblog &#187; Deployment</title>
	<atom:link href="http://lassebunk.dk/tag/deployment/feed/" rel="self" type="application/rss+xml" />
	<link>http://lassebunk.dk</link>
	<description>Ruby on Rails, programming, and SEO</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:51:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Getting your assets to work when upgrading to Rails 3.1</title>
		<link>http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/</link>
		<comments>http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 17:39:12 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Assets]]></category>
		<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Deployment]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1720</guid>
		<description><![CDATA[How to get the new Rails 3.1 assets pipeline working when upgrading or migrating from a Rails 3.0 app.]]></description>
			<content:encoded><![CDATA[<p>I was upgrading an app from Rails 3.0 to Rails 3.1 and had some trouble when it came to assets. Here&#8217;s how I got it to work.</p>
<h3>1. Upgrading to Rails 3.1</h3>
<p>Add Rails 3.1 to your Gemfile. Add or change the <code>gem 'rails'</code> line:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'rails', '3.1.0'
</pre>
<p>Bundle install:</p>
<pre class="brush: bash; title: ; notranslate">
$ bundle install
</pre>
<p>Run the update task to get your Rails files up to date, but beware! Just overwriting all files will probably mess up your app, so make sure to backup files or take notice of what changes you need to add to the new files before overwriting them. It will ask you what to do:</p>
<pre class="brush: bash; title: ; notranslate">
$ rake rails:update
</pre>
<p>Now your app should be running Rails 3.1. You can try running it using <code>rails s</code> but it probably won&#8217;t look great because we&#8217;ve not yet migrated the assets.</p>
<h3>2. Migrating your assets</h3>
<p>Try switching off the assets pipeline by commenting out the following line in <code>config/application.rb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
# config.assets.enabled = true
</pre>
<p>Your app should now be running as usual. If it doesn&#8217;t, try ironing out any issues before switching on the assets again:</p>
<pre class="brush: ruby; title: ; notranslate">
config.assets.enabled = true
</pre>
<p>We&#8217;re now ready to migrate the assets.</p>
<p>First, add this to your <code>Gemfile</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'jquery-rails'
group :assets do
  gem 'sass-rails', &quot;  ~&gt; 3.1.0&quot;
  gem 'coffee-rails', &quot;~&gt; 3.1.0&quot;
  gem 'uglifier'
end
</pre>
<p>And install:</p>
<pre class="brush: bash; title: ; notranslate">
$ bundle install
</pre>
<p>Now to the actual migration:</p>
<ol>
<li>Make sure you have the <code>images</code>, <code>javascripts</code>, and <code>stylesheets</code> folders in your <code>app/assets</code> folder.</li>
<li>Move all content from <code>public/images</code> into <code>app/assets/images</code>.</li>
<li>Move all content from <code>public/javascripts</code> into <code>app/assets/javascripts</code>.</li>
<li>Move all content from <code>public/stylesheets</code> into <code>app/assets/stylesheets</code>.</li>
</ol>
<p>Your javascripts and stylesheets will be compiled into a single <code>application.js</code> and <code>application.css</code>, so add or change this in your <code>app/views/layouts/application.html.erb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
&lt;%= stylesheet_link_tag 'application' %&gt;
&lt;%= javascript_include_tag 'application' %&gt;
</pre>
<p>To make sure that the assets generator will find all your javascripts and stylesheets, we will include all your javascripts in <code>application.js</code> and all your stylesheets in <code>application.css</code>. Assuming you are using jQuery, you can delete <code>jquery.js</code> and <code>jquery-ui.js</code> as they will be required and inserted automatically. Add the following to the top of <code>app/assets/javascripts/application.js</code>:</p>
<pre class="brush: jscript; title: ; notranslate">
//= require jquery
//= require jquery_ujs
//= require_tree .
</pre>
<p>And to the top of <code>app/assets/stylesheets/application.css</code>:</p>
<pre class="brush: css; title: ; notranslate">
/*
 *= require_self
 *= require_tree .
*/
</pre>
<p>Your javascripts and stylesheets will now be included automatically.</p>
<p>At last update all your image paths from <code>/images</code> to <code>/assets</code>. If you&#8217;re using the <code>image_tag</code> helper, all paths will be updated automatically.</p>
<h3>3. Deploying your assets</h3>
<p>Assuming you are deploying using <a href="https://github.com/capistrano/capistrano">Capistrano</a>, add the following to your <code>config/deploy.rb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
before &quot;deploy:symlink&quot;, &quot;assets:precompile&quot;

namespace :assets do
  desc &quot;Compile assets&quot;
  task :precompile, :roles =&gt; :app do
    run &quot;cd #{release_path} &amp;&amp; rake RAILS_ENV=#{rails_env} assets:precompile&quot;
  end
end
</pre>
<p>Your assets will now be compiled right before your app is moved into place in your production environment.</p>
<p>Try deploying your app:</p>
<pre class="brush: bash; title: ; notranslate">
$ cap deploy
</pre>
<p>If the deployment went as expected, great. If you get an error complaining about a missing JavaScript engine, try adding the following to the <code>assets</code> section of your <code>Gemfile</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'therubyracer'
</pre>
<p>And run the deployment again.</p>
<p>Your assets should now be in place! If you run into other problems, please write a comment below, and I&#8217;ll see if I can help.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails 3 and Bundler: Deploying gems using Capistrano</title>
		<link>http://lassebunk.dk/2010/09/01/rails-3-bundler-gems-capistrano/</link>
		<comments>http://lassebunk.dk/2010/09/01/rails-3-bundler-gems-capistrano/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 20:17:10 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[RubyGems]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1283</guid>
		<description><![CDATA[How to deploy gems from your Rails 3 application through Capistrano.]]></description>
			<content:encoded><![CDATA[<p>I have previously described how to <a href="http://lassebunk.dk/2009/07/18/deploying-gems-using-capistrano/">deploy gems using Capistrano</a> in a Rails 2 application. After upgrading to Rails 3, this has changed a bit. Rails now uses <a href="http://gembundler.com/">Bundler</a> for dependency management, so we need to use the <code>bundle install</code> command instead of <code>rake gems:install</code>.</p>
<p>In your <code>deploy.rb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
after &quot;deploy:update_code&quot;, &quot;bundle:install&quot;

namespace :bundle do
  desc &quot;Bundle install&quot;
  task :install, :roles =&gt; :app do
    run &quot;cd #{current_release} &amp;&amp; #{sudo} bundle install&quot;
  end
end
</pre>
<p>It&#8217;s as easy as that. Let me know if you have any comments.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2010/09/01/rails-3-bundler-gems-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Sinatra to serve smaller (than Rails) applications</title>
		<link>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/</link>
		<comments>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 14:19:55 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Rack]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1147</guid>
		<description><![CDATA[How to use Sinatra instead of Ruby on Rails to server small applications.]]></description>
			<content:encoded><![CDATA[<p>So, maybe you&#8217;ve been coding <a href="http://rubyonrails.org">Rails</a> for a while and wondered &#8211; &#8220;do I really need this full stack framework to serve even small applications?&#8221;. Well, no you don&#8217;t <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Check out <a href="http://dns.norbauer.com">Norbauer&#8217;s DNS Tools</a> (and on <a href="http://github.com/norbauer/dns-tools">Github</a>). It&#8217;s a small set of easy to use DNS tools. So small it would be overkill to serve it using Rails.</p>
<p>Norbauer&#8217;s using <a href="http://www.sinatrarb.com/">Sinatra</a> to serve the app.</p>
<p>Start by installing the gem:</p>
<pre class="brush: bash; title: ; notranslate">
$ sudo gem install sinatra
</pre>
<p>After that it&#8217;s as simple as this:</p>
<pre class="brush: ruby; title: ; notranslate">
# myapp.rb
require 'rubygems'
require 'sinatra'

get '/' do
  &quot;Welcome to my homepage!&quot;
end

get '/contact' do
  &quot;My contact info is...&quot;
end
</pre>
<p>At your terminal:</p>
<pre class="brush: bash; title: ; notranslate">
$ ruby myapp.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Mongrel
</pre>
<p>Now you can view it in your browser at <a href="http://localhost:4567">http://localhost:4567</a> and <a href="http://localhost:4567/contact">http://localhost:4567/contact</a>. Simple.</p>
<p>This is great for hosting apps from your command line (for example check out <a href="http://adam.blog.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/">Taps</a>) but what if you wanted to serve it like you would a Rails app?</p>
<p>Well, then you&#8217;d be using <a href="http://rack.rubyforge.org/">Rack</a>.</p>
<p>Create a file named <code>config.ru</code> in the same folder as <code>myapp.rb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'myapp'
run Sinatra::Application
</pre>
<p>Now you can deploy your application as you would if it was written in Rails (thanks to <code>config.ru</code>).<br />
If you want to check this setup at your localhost, run the following:</p>
<pre class="brush: bash; title: ; notranslate">
$ sudo gem install rack # make sure you have Rack installed
$ rackup # run the Rack application using config.ru
</pre>
<p>It&#8217;s as easy as that! Great for hosting small applications.</p>
<p>Also see:</p>
<ul>
<li><a href="http://rack.rubyforge.org/doc/">List of Rack compliant web servers</a></li>
<li><a href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">Deploying a Rack-based Ruby application [with Phusion Passenger]</a></li>
</ul>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

