Quantcast
Channel: Honolulu Hacker
Viewing all articles
Browse latest Browse all 20

Migrating my heroku/postgres project to Jruby

$
0
0

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:

  1. I made a branch of my project:
    git checkout -b jruby-test
  2. Install jruby via rvm
    rvm install jruby-1.6.2
  3. 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
  4. I updated my rmvc from :
    rvm use 1.9.2@proj

    to

    rvm use jruby-1.6.2@proj-jruby
  5. I edited my Gemfile. This is where I knew it would get tricky.
    1. Removed:
      gem 'pg'
    2. Added:
      gem 'activerecord-jdbc-adapter'
      gem 'activerecord-jdbcpostgresql-adapter'
      gem 'jdbc-postgres'
    3. Found out hard way had to remove ruby-debug19. DUh, dude :)
    4. 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.
  6. 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

  7. 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.


Viewing all articles
Browse latest Browse all 20

Trending Articles