<?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>Carl Mercier&#039;s blog &#187; rubyonrails</title>
	<atom:link href="http://blog.carlmercier.com/tag/rubyonrails/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.carlmercier.com</link>
	<description>me = entrepreneur + hacker;</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:38:06 +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>Running Merb on JRuby 1.2 and Glassfish 2.1</title>
		<link>http://blog.carlmercier.com/2009/03/30/running-merb-on-jruby-12-and-glassfish-21/</link>
		<comments>http://blog.carlmercier.com/2009/03/30/running-merb-on-jruby-12-and-glassfish-21/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 19:50:31 +0000</pubDate>
		<dc:creator>Carl Mercier</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://blog.carlmercier.com/?p=219</guid>
		<description><![CDATA[So I&#8217;ve been trying to get Merb running on JRuby a good part of last night. I don&#8217;t know jack about Java, so this has been a little bit more challenging than it should have been. Most (if not all) of the tutorials I found were old and obsolete, so I decided to throw out [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been trying to get Merb running on JRuby a good part of last night. I don&#8217;t know jack about Java, so this has been a little bit more challenging than it should have been.  Most (if not all) of the tutorials I found were old and obsolete, so I decided to throw out my very own.</p>
<p>I need to give credit to <a href="http://blog.nodeta.fi/2008/05/22/living-on-the-edge-jruby-merb-glassfish/" target="_blank">this page</a>, without which I&#8217;d still be fighting with this whole thing.</p>
<p>This tutorial uses JRuby 1.2, Glassfish 2.1, Merb 1.0.10 and Ubuntu 8.04 LTS. To make my life easy, I simply fired an EC2 instance based on ami-71fd1a18. I recommend you do the same.  However, it should work from just any vanilla Ubuntu 8.04.</p>
<p>Some important comments are in the script below, make sure to read them. Enjoy!</p>
<div class="code">
<!--start_raw--><br />
<textarea rows=30 cols=80><br />
# Setup the scene<br />
apt-get update<br />
apt-get upgrade<br />
# this is the Corporate World, folks, you&#8217;ll need to accept some license agreement in the next step<br />
apt-get install -y vim-full build-essential git-core sun-java6-jdk ant<br />
apt-get install -y mysql-server mysql-client</p>
<p># Install JRuby<br />
cd /tmp<br />
wget http://dist.codehaus.org/jruby/1.2.0/jruby-bin-1.2.0.tar.gz<br />
tar xzvf jruby-bin*<br />
mv jruby-1.2.0 /opt/jruby<br />
echo &#8220;export PATH=&#8221;/opt/jruby/bin:$PATH&#8221;" >> ~/.bashrc<br />
export PATH=&#8221;/opt/jruby/bin:$PATH&#8221;</p>
<p># By now, &#8216;jirb&#8217; should start IRB on JRuby!</p>
<p># Let&#8217;s now install some gems<br />
jruby -S gem install erubis rake json_pure rspec rack mime-types rubigen &#8211;no-rdoc &#8211;no-ri<br />
jruby -S gem install hpricot &#8211;no-rdoc &#8211;no-ri &#8211;version &#8216;~>0.6.1&#8242; # version 7 doesn&#8217;t work with JRuby as of now<br />
jruby -S gem install merb-core merb-more &#8211;no-rdoc &#8211;no-ri</p>
<p># Test to see if Merb is installed:<br />
jruby -S merb help</p>
<p># Create an Hello World app<br />
cd ~<br />
jruby -S merb-gen core hello_world<br />
cd hello_world<br />
jruby -S merb-gen controller hello<br />
echo &#8220;<br />
<h1>This is a Merb app running on JRuby. w00t!</h1>
<p>&#8221; > app/views/hello/index.html.erb<br />
# Freeze Merb into your app<br />
jruby -S gem install merb-core merb-more &#8211;no-rdoc &#8211;no-ri -i gems</p>
<p># Install Glassfish<br />
cd /tmp<br />
wget http://java.net/download/javaee5/v2.1_branch/promoted/Linux/glassfish-installer-v2.1-b60e-linux.jar<br />
# and yet more licensing!<br />
java -Xmx256m -jar glassfish-installer-v2.1-b60e-linux.jar<br />
mv glassfish /opt/<br />
cd /opt/glassfish<br />
ant -f setup.xml</p>
<p># Start Glassfish server, it might take some time.<br />
./bin/asadmin start-domain domain1</p>
<p># Warbler and friends<br />
jruby -S gem install rails warbler activerecord-jdbc-adapter &#8211;no-rdoc &#8211;no-ri<br />
cd ~/hello_world<br />
jruby -S warble config</p>
<p># Make sure frozen gems are included in your .war file.<br />
# edit config/warble.rb and add &#8220;gems&#8221; to the config.dirs line</p>
<p># create some missing directories, otherwise, warble will complain.<br />
mkdir -p lib log vendor<br />
# create a .war file<br />
jruby -S warble war<br />
# copy it to Glassfish.<br />
cp hello_world.war /opt/glassfish/domains/domain1/autodeploy/</p>
<p># Glassfish finds your app and starts it automatically.  Give it a few seconds.<br />
# Then, go to http://{server-ip}:4848<br />
# User: admin    Pass: adminadmin        Sounds like a good idea to change this for production!!!!!<br />
# Click &#8220;Web Applications&#8221;, then &#8220;hello_world&#8221;.  Change &#8220;Context Root&#8221; to &#8220;/&#8221; and Save.  Saving was slow for me.</p>
<p>#<br />
# That&#8217;s it!!!<br />
#<br />
# Now go see your l33t web 2.0 app in action:<br />
# Go to http://{server-ip}:8080/<br />
# and http://{server-ip}:8080/hello<br />
</textarea><br />
<!--end_raw-->
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlmercier.com/2009/03/30/running-merb-on-jruby-12-and-glassfish-21/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Announcing install_gems.rb</title>
		<link>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/</link>
		<comments>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 15:50:53 +0000</pubDate>
		<dc:creator>Carl Mercier</dc:creator>
				<category><![CDATA[Defensio]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[install_gems]]></category>
		<category><![CDATA[install_gems.rb]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://blog.carlmercier.com/?p=154</guid>
		<description><![CDATA[Over the weekend, I was rethinking the way we should deploy our Merb application (our API) for Defensio. Everything I&#8217;ll say here applies to Rails as well. Managing gems has been painful lately. Like most people, we&#8217;re freezing them, which helps tremendously. However, there&#8217;s a few problems with this approach: We can&#8217;t freeze C extensions [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend, I was rethinking the way we should deploy our Merb application (our API) for <a href="http://defensio.com" target="_blank">Defensio</a>.  Everything I&#8217;ll say here applies to Rails as well.</p>
<p>Managing gems has been painful lately.  Like most people, we&#8217;re freezing them, which helps tremendously.  However, there&#8217;s a few problems with this approach:</p>
<ul>
<li>We can&#8217;t freeze C extensions because they need to be compiled for the target platform.  We develop on OS X and Linux 64, but deploy to Linux i386.  As a workaround, we currently freeze but recompile them on every deployment.  Definitely not optimal.</li>
<li>Our frozen gems directory is getting huge.</li>
<li>It&#8217;s becoming complicated and quite a mess to manage multiple gem versions for different branches/tags.</li>
<li>We never quite know which branch needs which gem.</li>
</ul>
<p>Of course, we could manually install the gems we need on our servers.  But the word &#8220;manually&#8221; generally leads to &#8220;epic fail&#8221;.</p>
<p>So I thought, why not install them at deployment time, just before restarting the Mongrels, with Capistrano?  That seemed like a pretty good idea!  The only problem is that Rubygems will always install a gem when asked to do so, even if it&#8217;s already installed.</p>
<p>That&#8217;s where <a href="http://github.com/karabunga/install_gems/tree/master" target="_blank">install_gems.rb</a> comes in.  install_gems.rb takes a file name as an argument.  This file contains a simple list of gems along with their version number.  A custom installation command can also be specified.</p>
<p>Here&#8217;s an example:<br />
<code><br />
# This is an example file.  As you can see, it supports comments.<br />
haml 2.0.3<br />
eventmachine 0.12.2<br />
# Notice the custom command specified after the --<br />
termios 0.9.4 -- gem install termios -v 0.9.4 --no-rdoc --no-ri</p></blockquote>
<p></code></p>
<p>To install the above gems, you&#8217;d simply run<br />
<code>./install_gems.rb input_file</code></p>
<p>install_gems.rb has a few advantages over vanilla rubygems:</p>
<ul>
<li>It will only install a gem if the specified version is not already installed. That&#8217;s obviously much faster than reinstalling everything every time.</li>
<li>C extensions will be properly compiled.</li>
<li>Using different gem versions in different branches/tags/releases is now very easy.  You just have to maintain a list of required gems in your Git repository and make sure Capistrano runs install_gems.rb against this list before restarting the application servers.</li>
<li>It forces us to keep an up-to-date list of the gems we need.</li>
</ul>
<p>Of course, for this to work as expected, you&#8217;ll need to require specific gem versions in your application.  Your production server will likely have multiple versions of the same gems installed and if you don&#8217;t specify which version of the gem you want to require, things might (or will) break.</p>
<p>I released <a href="http://github.com/karabunga/install_gems/tree/master" target="_blank">install_gems.rb on GitHub</a> and <a href="http://danielharan.com" target="_blank">Daniel Haran</a> has already submitted a patch.  Feel free to do so as well, I&#8217;m a puller!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlmercier.com/2008/10/13/announcing-install_gemsrb/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to fix that Rubygems mess on Leopard</title>
		<link>http://blog.carlmercier.com/2007/12/14/how-to-fix-that-rubygems-mess-on-leopard/</link>
		<comments>http://blog.carlmercier.com/2007/12/14/how-to-fix-that-rubygems-mess-on-leopard/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 19:03:19 +0000</pubDate>
		<dc:creator>Carl Mercier</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://blog.carlmercier.com/2007/12/14/how-to-fix-that-rubygems-mess-on-leopard/</guid>
		<description><![CDATA[I love Leopard and I love my Mac. I think Apple made the right decision by bundling Ruby and Rails with Leopard. However, I believe they screwed up big time in the execution. Leopard&#8217;s Rails installation worked great until I updated Rubygems with sudo gem update &#8211;system. After I did that, most of my gems [...]]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://www.apple.com/macosx/" target="_blank">Leopard</a> and I love <a href="http://www.apple.com/macbookpro/" target="_blank">my Mac</a>.  I think Apple made the right decision by bundling <a href="http://ruby-lang.org" target="_blank">Ruby</a> and <a href="http://rubyonrails.org" target="_blank">Rails</a> with Leopard.  However, I believe they screwed up big time in the execution.</p>
<p>Leopard&#8217;s Rails installation worked great until I updated <a href="http://rubygems.org/" target="_blank">Rubygems</a> with <em>sudo gem update &#8211;system</em>. After I did that, most of my gems were broken, and reinstalling them didn&#8217;t help.   According to Google, <a href="http://discussions.apple.com/thread.jspa?threadID=1202925&amp;tstart=0" target="_blank">I was</a> <a href="http://www.luisdelarosa.com/2007/11/19/reinstalling-rubygems-on-leopard/" target="_blank">not alone</a>.</p>
<p>The right thing to do for Apple would have been to ship Leopard with <a href="http://www.macports.org/" target="_blank">MacPorts</a> and have Ruby and Rubygems installed through it.  Unfortunately, they had to reinvent the wheel&#8230;</p>
<p>This tutorial will guide you through fixing that mess.  We will be reinstalling Ruby and Rails with MacPorts and deleting the original Ruby installation to avoid conflicts.</p>
<p>You might want to backup your system before proceeding as I cannot be held responsible if something goes wrong (my lawyer made me write that).  I tried it on 2 different machines and it worked fine for me.</p>
<p>So let&#8217;s get started already!</p>
<p><strong>Step 1: Install MacPorts </strong></p>
<p>Start by installing <a href="http://www.macports.org/" target="_blank">MacPorts</a> if you don&#8217;t already have it on your machine.  It&#8217;s an awesome must-have piece of software anyways!  It&#8217;s super easy to install with the Leopard package.</p>
<p><strong>Step 2: Install XCode 3.0</strong></p>
<p>You must also have <a href="http://developer.apple.com/tools/download/" target="_blank">XCode 3.0</a> installed. It&#8217;s a huge download so you might want to install it from your Leopard DVD.  It&#8217;s in <em>/Optional Installs/Xcode Tools/XcodeTools.mpkg  </em></p>
<p>Installation will take some time, so go read <a href="http://digg.com" target="_blank">Digg</a>, <a href="http://reddit.com" target="_blank">Reddit</a>, or install <a href="http://defensio.com" target="_blank">Defensio</a> on your blog!</p>
<p><strong>Step 3: List your gems</strong></p>
<p>Get a list of your installed gems and save it to a text file somewhere.  You will need to reinstall them! [source:php]gem list &gt; ~/Desktop/installed_gems.txt[/source]</p>
<p><strong>Step 4: Clean up your Mac</strong></p>
<p>In order to avoid conflicts with your original Ruby installation, I recommend you simply delete it. To do so, run these commands (I know&#8230; scary stuff!):[source:php]sudo rm -r /System/Library/Frameworks/Ruby.framework/<br />
sudo rm -r /Library/Ruby<br />
sudo rm /usr/bin/ruby<br />
sudo rm /usr/bin/gem<br />
[/source]</p>
<p><strong>Step 5: Install Ruby and Rubygems with MacPorts</strong></p>
<p>If you don&#8217;t perform step 4, <strong>you will run into problems </strong>at step 6.</p>
<p>Now go ahead and install Rubygems through MacPorts.  It will automatically install Ruby (and many other things) as it&#8217;s a dependency.  The command is: [source:php]sudo port install rb-rubygems[/source]</p>
<p>This one will also take a while&#8230; When it&#8217;s done, update Rubygems: [source:php]sudo gem update &#8211;system[/source]</p>
<p><strong>Step 6: Install Rails</strong></p>
<p>At this point, you should have a brand new Ruby and Rubygems installation working!   That wasn&#8217;t too hard was it?</p>
<p>Now let&#8217;s install Rails.</p>
<ul>
<li>For Rails 1.2.6, run [source:php]sudo gem install rails -v 1.2.6[/source]</li>
<li>For Rails 2 (aka latest-and-greatest), run [source:php]sudo gem install rails[/source]</li>
</ul>
<p>Note that recent versions of Rubygems no longer requires the &#8211;include-dependencies parameter.</p>
<p><strong>Step 7: Reinstall your gems </strong></p>
<p>Now&#8217;s the time to reinstall your original gems.</p>
<p>To reinstall the gems that shipped with Leopard, execute this command: [source:php]sudo gem install RedCloth acts_as_ferret mongrel fcgi capistrano ruby-openid ferret dnssd hpricot sqlite3-ruby libxml-ruby termios[/source]</p>
<p>Then, you might want to reinstall the other gems you had.  The list is on your desktop in <em>installed_gems.txt</em>.</p>
<p>That&#8217;s it!  You now have a more standard and less prone to problems Rails stack on your Mac!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlmercier.com/2007/12/14/how-to-fix-that-rubygems-mess-on-leopard/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Deploying Rails on the Cheap</title>
		<link>http://blog.carlmercier.com/2007/12/05/deploying-rails-on-the-cheap/</link>
		<comments>http://blog.carlmercier.com/2007/12/05/deploying-rails-on-the-cheap/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 16:52:37 +0000</pubDate>
		<dc:creator>Carl Mercier</dc:creator>
				<category><![CDATA[Presentations]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[montrealonrails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[scaling]]></category>
		<category><![CDATA[shared]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://blog.carlmercier.com/2007/12/05/deploying-rails-on-the-cheap/</guid>
		<description><![CDATA[Yesterday, I presented at Montreal on Rails.  What a great crowd it was! As promised, here are my slides.  Feel free to get in touch if you have any question about my presentation.]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I presented at <a href="http://montrealonrails.com" target="_blank">Montreal on Rails</a>.  What a great crowd it was!</p>
<p>As promised, <a href="http://blog.carlmercier.com/wp-content/uploads/2007/12/mor5_deploying_rails_on_the_cheap.ppt">here are my slides</a>.  Feel free to get in touch if you have any question about my presentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlmercier.com/2007/12/05/deploying-rails-on-the-cheap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

