Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Rails 2 on Windows with Oracle: notes about getting started

I’m planning to make this the first in a series of random small notes
about working on a Rails project in an enterprise (by which I mean large-scale, mature-company, high-demand) setting. I’m aiming for small bite-sized dispatches, not for comprehensiveness. [Edited to say: I’m now working on a Java project, so I’m not sure when I will have more to add.] Please
chime on in with additions and comments. This post focuses on our installation process. If you’ve gotten here via google, you’re going to find much more systematic guides than this, so be of good cheer!

To get going on Windows XP (which really didn’t take long after we received admin permissions for our PC) we began by installing and
configuring Cygwin. There are many good Cygwin resources, so I’ll just note that being proxied inside a firewall, we needed to set our ‘http_proxy’ environment variable to a fully qualified proxy URL (http://proxy_host:port) in order for gem to be able to pull packages down.

Also (maybe unnecessary if we got all our paths right, but I’ve had this kind of path wonkiness in Cygwin before) we needed to
alias rake, rails and gem, as in "alias gem='/cygdrive/c/ruby/bin/ruby

We froze to Edge rails. We installed mySql first, did some scaffolding out of resources (I do love script/generate Noun) so that we had some migrations to apply. Then we made the transition to Oracle 10g local install (free).

You’ll need oci8, the Oracle connection layer. In case you miss this the way I did, there’s a binary Windows installer there for you — download it and run ruby ruby-oci8-1.0.0-mswin32.rb.

Current Rails 2 also omits the oracle connection adapter: put it in with the other connection adapters in ${RUBY_HOME}/lib/ruby/gems/1.8/gems/lib/active_record/connection_adapters/

At the moment you’ll also need to make this patch to the adapter.

Our project has a requirement for different table names than the Rails-guessable default. (The requirement is that they differ even within an Oracle view.) For this case, any database will need you to set the table name (we had trouble with set_table_name, but we were able to use def self.table_name() "my_actual_table_name" end ). With Oracle, and I would imagine with Postgres, you also need to set the sequence name:

   set_sequence_name "my_actual_table_name_seq"

or you get a “sequence does not exist” error. We flipped back to MySql at one point and didn’t get any complaints about setting sequence names in each model object, so that’s good.

If you insert data in your migrations and you have explicitly set sequence names, don’t forget that you will have to make the ID one of the inserted columns, with the value being my_actual_table_name_seq.nextval. If you aren’t monkeying with table names, ignore all of this, because the adapter will take care of sequences behind the scenes.

We tried applying a global prefix to our table names, because the prefix is the non-guessable part, but didn’t manage to make that work, presumably because we hadn’t yet figured out the sequence naming issue.

We’ve done a quick experiment with creating an updatable view, to make sure we can make that work with Rails (since the database schema is already specified and is not very Rails-friendly, we’ll mask that with views), and it just worked. The sequence gets called appropriately by the adapter for the ID. (I initially had some doubt about this, but it was just because I messed up the first version of my view by leaving out the ID field.)

Dropping the database from rake doesn’t seem to work. More importantly, we have a still-unsolved issue with not being able to reliably run “rake test” — the migration process breaks sporadically. (Individual tests run outside of rake from the command line are fine.) Our current fix is that we put the following test suite in test/test_suite.rb

       require 'test/unit'

       @@test_files = Dir.glob("**/*_test.rb")
       @@test_files.each {|x| require "test/" + x unless x.include?("selenium")}

and we’re running it from IntelliJ.

That’s probably more than enough for today. I’m on vacation for a couple of weeks. So if you share your own Oracle/Rails tips while I’m gone, I won’t be able to thank you till March… but don’t let that discourage you!

  1. Viktor says:

    Thanks for this post. I will be trying out and installing this soon.

  2. Natashiya says:

    This post is very helpful. I’ll tell my friend about this and maybe we could try doing this. Thanks!

  3. This post *is* very helpful. I”ll tell my friend about this too and maybe we could try doing this also. Thanks!

  4. Brendan says:

    Were Windows XP and Oracle used to demonstrate that Rails is “Enterprisey”, or is this actually the platform that you plan on deploying?

    I wouldn’t think these would be the optimal choices for a “large-scale, […] high-demand setting”. Scaling horizontally is far better than scaling vertically, but will incur a ton of additional cost for software licenses if this is your setup.

    Of course, you’ll be pretty limited if you’re building on top of already existing infrastructure. When the choice is mine, however, I always go for Linux and PostgreSQL or MySQL.

  5. Shifra Pride Raffel says:

    Glad people are interested in this. (Wes, is your friend named Natashiya by any chance?)

    Brendan, thanks for reminding me to say that this is just our development environment. We’ll be on Linux and Oracle for production, but we didn’t have control over anything but a local Windows box to start with.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *