A little inspired by all the JRuby buzz, I thought I’d take an existing rails app that I have running on heroku and migrate it to Jruby. I wanted to test how easy/hard it would be:
- I made a branch of my project:
git checkout -b jruby-test
- Install jruby via rvm
rvm install jruby-1.6.2
- I editted my .rvmc to use Jruby instead of MRI, from:
rvm use 1.9.2@proj
to
rvm use jruby-1.6.2@proj-jruby
- I updated my rmvc from :
rvm use 1.9.2@proj
to
rvm use jruby-1.6.2@proj-jruby
-
I edited my Gemfile. This is where I knew it would get tricky.
- Removed:
gem 'pg'
- Added:
gem 'activerecord-jdbc-adapter' gem 'activerecord-jdbcpostgresql-adapter' gem 'jdbc-postgres'
- Found out hard way had to remove ruby-debug19. DUh, dude
- Texticle gem does not work. This makes sense because it is plugin to postgres ActiveRecord driver. However, I use this for my minimalistic search functionality.
- Removed:
- Ran ‘rake spec’ on the project. My tests for the search feature failed as expected because of the missing Texticle dependency. I had one test that was failing on
Regular expression. The regular expression looked like this:if last_item =~ /sector|leverage_point/
When examined the code a bit, I found out that last_item was actually a symbol. I guess MRI automatically converts symbols to strings for Regular Expressions and JRuby does not. I changed the line to:
if last_item.to_s =~ /sector|leverage_point/
and it worked fine
- Ran ‘rails s thin’ and my app was up and running.
Not bad for a JRuby amatuer. Although not having the Texticle gem is a show stopper on this project.
It’s not that Texticle is the best solution for search but we have some code written in it.