Skip to content

NoMethodError: undefined method `eq’ for nil:NilClass

JRuby 1.5.2
Rails 3.0
activerecord-jdbc-adapter 0.9.7

This issue arises when setting table name with a schema name prefix. For those in the know – this is a must-have if you’re connecting to oracle using a non-owner username (activerecord-jdbc-adapter).

Now – tracking this down led to

The @@tables include table names as read from the connection (sans schema name). The comparison with the name always yields false resulting in an instantiation of an empty Header (with no attributes). Hence – alias_table[<attr>] always returned nil and nil.eq is undefined.

Anyways – as a work around (sorry: non tested monkey patch):

in your apps lib folder (provided that it’s auto-loaded) – create the arel_ext.rb

Reported on activerecord-jdbc-adapter list:

Posted in Java, Ruby.

4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. david says

    Hey thanks for this, just a heads-up that @@tables no longer works, have to just use tables

  2. Omaer says

    I think this might be related to my problem.
    Using Rails 3 with MS Sql Server 05.
    Legacy tables -> with different names, non auto-incrementing primary key.

    Model Code:
    class Station < ActiveRecord::Base
    self.table_name = "ZDS_SA_STATION"
    self.primary_key = "ID_Station"

    View Code:

    And I’m getting the error. I do hope this gets resolved ASAP!

  3. Tamer says

    @Omaer – have you tried using set_table_name and set_primary_key instead? Not sure if that would change anything but give it a try.

    The issue corresponds to the activerecord-jdbc-adapter which I think is not the same as the adapter you are using. However, that “No Method Error” could be due to a lot of things. Try following your stack trace and see where the source of the issue is.


  4. Tamer says

    @david – thanks for the heads-up

Some HTML is OK

or, reply to this post via trackback.