Nick Sieger: JRuby and Rails 3, Sitting in a Tree
tag:blog.nicksieger.com,2005:Typo
Typo
2010-11-22T18:03:45+00:00
Nick Sieger
urn:uuid:603837d6-55bf-4e03-8fec-4d2db26c002e
2010-02-24T03:58:00+00:00
2010-11-22T18:03:45+00:00
JRuby and Rails 3, Sitting in a Tree
<h2>Synopsis</h2>
<pre><code>jruby -S rails new myapp -m http://jruby.org/rails3.rb
</code></pre>
<p>When creating your Rails 3 application, just add the JRuby-specific template (<code>-m http://jruby.org/rails3.rb</code>).</p>
<h2>Details</h2>
<pre><code>$ jruby -S gem install rails --pre --no-rdoc --no-ri
Due to a rubygems bug, you must uninstall all older versions of bundler for 0.9 to work
Successfully installed i18n-0.3.3
Successfully installed tzinfo-0.3.16
Successfully installed builder-2.1.2
Successfully installed memcache-client-1.7.8
Successfully installed activesupport-3.0.0.beta
Successfully installed activemodel-3.0.0.beta
Successfully installed rack-1.1.0
Successfully installed rack-test-0.5.3
Successfully installed rack-mount-0.4.7
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.5
Successfully installed actionpack-3.0.0.beta
Successfully installed arel-0.2.1
Successfully installed activerecord-3.0.0.beta
Successfully installed activeresource-3.0.0.beta
Successfully installed mime-types-1.16
Successfully installed mail-2.1.3
Successfully installed text-hyphen-1.0.0
Successfully installed text-format-1.0.0
Successfully installed actionmailer-3.0.0.beta
Successfully installed thor-0.13.3
Successfully installed railties-3.0.0.beta
Successfully installed bundler-0.9.7
Successfully installed rails-3.0.0.beta
24 gems installed
</code></pre>
<h3>And:</h3>
<pre><code>$ jruby -S gem install activerecord-jdbcsqlite3-adapter --no-rdoc --no-ri
Successfully installed activerecord-jdbc-adapter-0.9.3-java
Successfully installed jdbc-sqlite3-3.6.3.054
Successfully installed activerecord-jdbcsqlite3-adapter-0.9.3-java
3 gems installed
</code></pre>
<h3>Finally:</h3>
<pre><code>$ jruby -S rails new myapp -m http://jruby.org/rails3.rb
create
...(app creation)...
apply http://jruby.org/rails3.rb
apply http://jruby.org/templates/default.rb
gsub Gemfile
run jruby script/rails generate jdbc from "."
...(warnings omitted)...
exist
create config/initializers/jdbc.rb
create lib/tasks/jdbc.rake
$ cd myapp
$ jruby script/rails server
...(warnings omitted)...
=> Booting WEBrick
=> Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-02-23 19:44:26] INFO WEBrick 1.3.1
[2010-02-23 19:44:26] INFO ruby 1.8.7 (2010-02-23) [java]
[2010-02-23 19:44:26] INFO WEBrick::HTTPServer#start: pid=16449 port=3000
</code></pre>
<p><img src="http://img.skitch.com/20100224-eik9e957x7uu8k5x8y4xgt9jes.jpg" alt="rails-welcome"/></p>
<h2>Recap</h2>
<p>You’ll have best results with <a href="http://ci.jruby.org/snapshots">JRuby 1.5 snapshots</a>, which include RubyGems 1.3.6. JRuby 1.5 final is coming soon. Also, <a href="http://rubyforge.org/forum/forum.php?forum_id=36489">the new <code>activerecord-jdbc-adapter</code> 0.9.3 release</a> is required for Rails 3 compatibility.</p>
<p>The Rails experience on JRuby continues to get better.</p>