<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Learning Journey</title>
	<atom:link href="http://tamersalama.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tamersalama.com</link>
	<description>of Tamer Salama</description>
	<lastBuildDate>Wed, 07 Dec 2011 00:44:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>JQuery Autocomplete updating a document element (not the dropdown)</title>
		<link>http://tamersalama.com/2011/12/06/jquery-autocomplete-updating-a-document-element-element-not-a-dropdown/</link>
		<comments>http://tamersalama.com/2011/12/06/jquery-autocomplete-updating-a-document-element-element-not-a-dropdown/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 00:38:51 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=960</guid>
		<description><![CDATA[I came across the requirement of updating a page element from the result of an Autocomplete. The server results were to be placed in a select element as set of option items. I had to overwrite some JQuery UI Autocomplete private methods as apparently there was no easy way of generating HTML and embedding it [...]]]></description>
			<content:encoded><![CDATA[<p>I came across the requirement of updating a page element from the result of an Autocomplete. The server results were to be placed in a select element as set of option items.</p>
<p>I had to overwrite some <a href="https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.autocomplete.js" title="JQuery UI Autocomplete">JQuery UI Autocomplete</a> private methods as apparently there was no easy way of generating HTML and embedding it in the right spot on the page:</p>
<p>The JSON server response:</p>
<pre><code>[{"id":"aaa","id_and_ba_name":"bbb"}, ...]</code></pre>
<pre>
<code>
   var auto = $("#lc").autocomplete({
      minLength: 3,
      delay: 600,
      dataType: 'json',
      source: '/remote/action',
      open: function() {
         $("ul.ui-autocomplete").remove(); //removes the ul styling for dropdown
      }
    })
    auto.data("autocomplete")._renderMenu= function(element, items) {
      //treats the DOM element as the menu where items are to be placed
      var self = this;
      $('#the_select_element').show().html('');
      $.each( items, function( index, item ) {
        self._renderItem($('#the_select_element'), item );
      });
    }
    auto.data("autocomplete")._renderItem= function(element, item) {
       // generate options elements and adds them to menu
       return $("&lt;option>&lt;/option>")
        .data("item.autocomplete",item)
        .attr("value",item.id)
        .append(item.id_and_ba_name)
        .appendTo(element);
    }
</code>
</pre>
<p>JQuery 1.8.16<br />
Rails 3.1</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/12/06/jquery-autocomplete-updating-a-document-element-element-not-a-dropdown/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JRuby and Polyglot</title>
		<link>http://tamersalama.com/2011/11/17/jruby-and-polyglot/</link>
		<comments>http://tamersalama.com/2011/11/17/jruby-and-polyglot/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 03:02:24 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=954</guid>
		<description><![CDATA[JRuby 1.5.6 (I know. Old) Rails 3.0.1 Polyglot 0.3.3 UPDATE: see easier fix below Getting the following error when bundling: Java::JavaLang::ArrayIndexOutOfBoundsException: An error occured while installing polyglot (0.3.3), and Bundler cannot continue. Make sure that `gem install polyglot -v '0.3.3'` succeeds before bundling. JRuby YAML parser is erring with this version of Polyglot (don&#8217;t you [...]]]></description>
			<content:encoded><![CDATA[<p>JRuby 1.5.6 (I know. Old)<br />
Rails 3.0.1<br />
Polyglot 0.3.3</p>
<p>UPDATE: see easier fix below</p>
<p>Getting the following error when bundling:<br />
<code></p>
<pre>
Java::JavaLang::ArrayIndexOutOfBoundsException: An error occured while installing polyglot (0.3.3), and Bundler cannot continue.
Make sure that `gem install polyglot -v '0.3.3'` succeeds before bundling.
</pre>
<p></code></p>
<p>JRuby YAML parser is erring with this version of Polyglot (don&#8217;t you love JRuby!!).</p>
<p>&#8216;gem dependency -R polyglot&#8217; will get you the reverse dependencies on the library. In this case it&#8217;s &#8216;treetop&#8217;</p>
<p>Had to edit the &#8216;gemspec&#8217; files and restrict the version of polyglot to &#8216;< 0.3.3'</p>
<p>Example - From<br />
s.add_runtime_dependency(%q
<polyglot>, [">= 0"])<br />
To<br />
s.add_runtime_dependency(%q
<polyglot>, [">= 0", "< 0.3.3"])</p>
<p>Yak shaving!!!</p>
<p>UPDATE: EASIER FIX:<br />
just use `gem &#8216;polyglot&#8217;, &#8217;0.3.2&#8242;` in your Gemfile, it might just do the trick.</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/11/17/jruby-and-polyglot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails, nested attributes and before_save callbacks</title>
		<link>http://tamersalama.com/2011/11/10/rails-nested-attributes-and-before_save-callbacks/</link>
		<comments>http://tamersalama.com/2011/11/10/rails-nested-attributes-and-before_save-callbacks/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 00:46:52 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=947</guid>
		<description><![CDATA[I had a Project model with a many ProjectWell (as in oil) association. Taking advantage of the accepts_nested_attributes, I was able to persist both Project and ProjectWell attributes through a single web form. class Project < ActiveRecord::Base has_many :project_wells accepts_nested_attributes_for :project_wells end class ProjectWell < ActiveRecord::Base belongs_to :project end Now, the ProjectWell had fields that [...]]]></description>
			<content:encoded><![CDATA[<p>I had a Project model with a many ProjectWell (as in oil) association. Taking advantage of the accepts_nested_attributes, I was able to persist both Project and ProjectWell attributes through a single web form.</p>
<pre>
<code>
class Project < ActiveRecord::Base
  has_many :project_wells
  accepts_nested_attributes_for :project_wells
end

class ProjectWell < ActiveRecord::Base
  belongs_to :project
end
</code>
</pre>
<p>Now, the ProjectWell had fields that I wanted to calculate and assign on each ProjectWell save. Naturally a before_save operation (within an observer or such) would've been sufficient. The main requirement I had was to have all ProjectWell callbacks fired regardless of the Dirty state of the ProjectWell object.</p>
<p>Given Project p with an associated ProjectWell p_well (both already exist in the database):</p>
<pre>
<code>
p.update_attributes!({"project_well_attributes" => [{'id' => p_well.id, 'name' => p_well.name}]})
</code>
</pre>
<p>This will NOT update the ProjectWell (p_well) object in the database, and hence will NOT fire any of the required callbacks. The main reason is that the p_well attributes didn't change. The name attribute is the same as the one already in persisted.</p>
<p>My next attempt was to try to disable the partial_updates for ActiveRecord. In an initializer, I've placed this configuration:</p>
<pre>
<code>
ActiveRecord::Base.partial_updates = false
</code>
</pre>
<p>What this does was disable selective attribute updates for ProjectWells (and all other objects). In other words; it updates all ProjectWell attributes, regardless of whether or not those particular attributes have changed. But this happens ONLY when ActiveRecord detects at least ONE changed attributes.</p>
<p>In my case, there were no changes in any of the attributes, which made Rails skip the update operation altogether.</p>
<p>My work around was to 'simulate' an attribute change, in one of the attributes, even if it hasn't really changed by the user.</p>
<p>A first attempt was to create a virtual (non-persisted) attribute in the model (attr_accessor :force_save). Unfortunately, it changes to the attribute (corresponding to its default value) didn't trigger Rails dirty check.</p>
<p>A second attempt was by using '_will_change!' dynamic method. The method can force Rails into registering the corresponding attribute as a changed one.</p>
<pre>
<code>
  def force_save= val
    force_save_will_change!
    @force_save= val
  end
</pre>
<p></code></p>
<p>This threw an undefined method error of 'force_save_will_change!'.</p>
<p>The _will_change! method is only available for DB persisted attributes (defined in the corresponding table).</p>
<p>My next attempt made by selecting a non-virtual attribute to use the will_change! against.</p>
<pre>
<code>
  def name= val
    name_will_change!
    @name= val
  end
</pre>
<p></code></p>
<p>This resolved the issue by always setting the ProjectWell state to dirty update an update to name attribute, regardless if the previous name was the same as the new one.</p>
<p>Now, when executing the update_attributes - passing in the name attribute (whether with a name change or not) will fire off the save operation and consequently the before_save callback</p>
<p>Note: Setting 'autosave' and 'touch' on the relative association declaration didn't help.</p>
<p>Any other way of doing this?</p>
<p>Stack: Rails 3.1.0, JRuby 1.63, activerecord-oracle_enhanced-adapter 1.4, Windows XP</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/11/10/rails-nested-attributes-and-before_save-callbacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FactoryGirl with Oracle enhanced adapter &#8211; an attribute of name &#8216;id&#8217; is not assigned</title>
		<link>http://tamersalama.com/2011/10/18/factorygirl-with-oracle-enhanced-adapter-an-attribute-of-name-id-is-not-assigned/</link>
		<comments>http://tamersalama.com/2011/10/18/factorygirl-with-oracle-enhanced-adapter-an-attribute-of-name-id-is-not-assigned/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 15:53:31 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=941</guid>
		<description><![CDATA[My question and answer are also posted on StackOverflow I have an Oracle test table with ID column that is not a primary key, not an autoincrement and with no sequence defined. It only has NOT NULL defined. The corresponding structure in development schema is an Oracle View rather than a table with a primary [...]]]></description>
			<content:encoded><![CDATA[<p>My question and answer are also posted on <a href="http://stackoverflow.com/questions/7808487/factorygirl-with-oracle-enhanced-adapter-an-attribute-of-name-id-is-not-assi/7810070">StackOverflow</a></p>
<p>I have an Oracle test table with ID column that is not a primary key, not an autoincrement and with no sequence defined. It only has NOT NULL defined. The corresponding structure in development schema is an Oracle View rather than a table with a primary key defined against the ID column.</p>
<p>My factory definition looks like:</p>
<pre><code>
FactoryGirl.define do
  factory :model do
    id 'abc'
  end
end
</pre>
<p></code></p>
<p>These tests fails</p>
<pre><code>
test "should build model 1" do
  w = FactoryGirl.build(:model)
  assert_not_nil w.id #fails - id is always nil
end

test "should build model 2" do
  w = FactoryGirl.build(:model, :id => 'abc')
  assert_not_nil w.id #fails - id is always nil
end
</pre>
<p></code></p>
<p>I've added attr_accessible :id to my model (just in case), but with no luck.</p>
<p>I've also defined id= method in my model def id= id; @id = id; end. The call is made to the method and @id is written, but looks like it is overwritten later in the callstack (between FactoryGirl and ActiveRecord).</p>
<p>Other attributes are normally assigned.</p>
<p>After a bit of digging - I found the I found the culprit:</p>
<p>The write method in ActiveRecord::AttributeMethods::Write module has the line:</p>
<pre><code>
attr_name = self.class.primary_key if attr_name == 'id'
</pre>
<p></code></p>
<p>It means that if the attribute name to be set has the name of 'id', pick the primary_key as the name of the attribute to assign the new value to. And since in my test table there is no primary_key returned by the oracle_enhanced_adapter (rightfully), the whole write operation is skipped.</p>
<p>My solution was to override the write method (only when running tests) skipping that line so that the id is written to.</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/10/18/factorygirl-with-oracle-enhanced-adapter-an-attribute-of-name-id-is-not-assigned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Oracle Database Views with Rails</title>
		<link>http://tamersalama.com/2011/10/17/test-oracle-database-views-with-rails/</link>
		<comments>http://tamersalama.com/2011/10/17/test-oracle-database-views-with-rails/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 21:29:33 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=935</guid>
		<description><![CDATA[Testing Rails with a legacy oracle schema as a backend is always a challenge (fun?). Rails relies no schema.rb to create its test database. The problem is that using the latest activerecord-oracle_enhanced-adapter (1.4.0), the application is unaware of the database views. So, I&#8217;ve decided to create those DB views (development) as DB tables (test). #names [...]]]></description>
			<content:encoded><![CDATA[<p>Testing Rails with a legacy oracle schema as a backend is always a challenge (fun?).</p>
<p>Rails relies no schema.rb to create its test database. The problem is that using the latest activerecord-oracle_enhanced-adapter (1.4.0), the application is unaware of the database views.</p>
<p>So, I&#8217;ve decided to create those DB views (development) as DB tables (test).</p>
<pre>
<code>
#names of views I'd like created
views = %W(VIEW1 VIEW2 VIEW2)
dev_schema = Rails.configuration.database_configuration["development"]["username"].upcase
test_schema = Rails.configuration.database_configuration["test"]["username"].upcase
views.each do |view|
  #for each of the views I need created
  # establish a connection first to development database
  ActiveRecord::Base.establish_connection(:development)
  # grant select on the view to the test user
  ActiveRecord::Base.connection.execute  "GRANT SELECT ON #{dev_schema}.#{view} TO #{test_schema}"
  # establish a connection to the test database
  ActiveRecord::Base.establish_connection(:test)
  # create the view as a table in the test database - 'where 1=0' discards importing data
  ActiveRecord::Base.connection.execute "CREATE TABLE #{test_schema}.#{view} AS SELECT * FROM #{dev_schema}.#{view} where 1=0"
end

</code>
</pre>
<p>The script can run as a db:test:prepare rake task or as being explicitly required somewhere at the beginning of the test_helper. And of course, this is just the initial working concept &#8211; it can be greatly improved.</p>
<p>JRuby 1.6.3<br />
Rails 3.1<br />
activerecord-oracle_enhanced-adapter 1.4.0</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/10/17/test-oracle-database-views-with-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Die IE7. Die.</title>
		<link>http://tamersalama.com/2011/01/14/die-ie7-die/</link>
		<comments>http://tamersalama.com/2011/01/14/die-ie7-die/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 00:46:45 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=932</guid>
		<description><![CDATA[getElementById Method: Returns a reference to the first object with the specified value of the ID or NAME attribute. Why the heck a method with called &#8220;getElementByID&#8221; return NAME matches?! Here&#8217;s the story: Two elements with different IDs, with one of the IDs matching the name of the other. &#60;textarea id="X" name="A"&#62;First&#60;/textarea&#62; &#60;textarea id="A" name="whatever"&#62;Second&#60;/textarea&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>getElementById Method: Returns a reference to the first object with the specified value of the ID <strong><em>or NAME</em></strong> attribute.</p>
<p>Why the heck a method with called &#8220;getElementByID&#8221; return NAME matches?!</p>
<p>Here&#8217;s the story:</p>
<p>Two elements with different IDs, with one of the IDs matching the name of the other.</p>
<pre><code>
&lt;textarea id="X" name="A"&gt;First&lt;/textarea&gt;
&lt;textarea id="A" name="whatever"&gt;Second&lt;/textarea&gt;

document.getElementById('X').value
/* will return 'First' */

document.getElementById('A').value
/* will also return 'First' */
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/01/14/die-ie7-die/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; disable timezone conversions</title>
		<link>http://tamersalama.com/2011/01/10/rails-disable-timezone-conversions/</link>
		<comments>http://tamersalama.com/2011/01/10/rails-disable-timezone-conversions/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 01:40:42 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=928</guid>
		<description><![CDATA[In order to globally disable the use of TimeZone conversions for your (legacy?) application &#8211; here&#8217;s the proper configurations: In config/application.rb (or config/environment.rb depending on Rails version): config.time_zone = 'Mountain Time (US &#038; Canada)' #uncommented and set to proper zone config.active_record.default_timezone = :local config.active_record.time_zone_aware_attributes = false]]></description>
			<content:encoded><![CDATA[<p>In order to globally disable the use of TimeZone conversions for your (legacy?) application &#8211; here&#8217;s the proper configurations:</p>
<p>In config/application.rb (or config/environment.rb depending on Rails version):</p>
<pre>
<code>
    config.time_zone = 'Mountain Time (US &#038; Canada)' #uncommented and set to proper zone
    config.active_record.default_timezone = :local
    config.active_record.time_zone_aware_attributes = false
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2011/01/10/rails-disable-timezone-conversions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heroku timezone adjustment</title>
		<link>http://tamersalama.com/2010/10/05/heroku-timezone-adjustment/</link>
		<comments>http://tamersalama.com/2010/10/05/heroku-timezone-adjustment/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 06:28:44 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=923</guid>
		<description><![CDATA[Setting up timezone on Heroku instance using heroku gem (command line) heroku config:add TZ=America/Edmonton .... heroku console &#62;&#62; Time.now =&#62; ... -0700 ... Heroku apparently accepts zoneinfo timezones.]]></description>
			<content:encoded><![CDATA[<p>Setting up timezone on Heroku instance using heroku gem (command line)</p>
<pre>heroku config:add TZ=America/Edmonton
....
heroku console
&gt;&gt; Time.now
=&gt; ... -0700 ...</pre>
<p>Heroku apparently accepts <a href="http://en.wikipedia.org/wiki/List_of_tz_database_time_zones">zoneinfo timezones</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2010/10/05/heroku-timezone-adjustment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Contents Invalid public key / Fingerprint can&#8217;t be blank</title>
		<link>http://tamersalama.com/2010/10/04/contents-invalid-public-key-fingerprint-cant-be-blank/</link>
		<comments>http://tamersalama.com/2010/10/04/contents-invalid-public-key-fingerprint-cant-be-blank/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 02:33:10 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=918</guid>
		<description><![CDATA[Getting the above error message trying to deploy to Heroku (Windows, PuTTY keygen). Turns out the public/private key files saved through putty aren&#8217;t of a valid OpenSSH format (expected by Heroku). You can still use Putty Keygen by copying the text generated under &#8220;Public key for pasting into OpenSSH authorized_key file&#8221; (save it to your [...]]]></description>
			<content:encoded><![CDATA[<p>Getting the above error message trying to deploy to Heroku (Windows, PuTTY keygen).</p>
<p>Turns out the public/private key files saved through putty aren&#8217;t of a valid OpenSSH format (expected by Heroku). You can still use Putty Keygen by copying the text generated under &#8220;Public key for pasting into OpenSSH authorized_key file&#8221; (save it to your *.pub)</p>
<p>I&#8217;m inching towards my first Mac. Windows is a frustration after the other.</p>
<p>UPDATE: working with Heroku/Git/SSH on a windows machine is a royal pain. One step closer to a MaxBook.</p>
<p>Follow these if you&#8217;re stuck:<br />
- <a href="http://therubyway.wordpress.com/2008/12/11/using-heroku-and-windows/">http://therubyway.wordpress.com/2008/12/11/using-heroku-and-windows/</a><br />
- <a href="http://linux-sxs.org/networking/openssh.putty.html">http://linux-sxs.org/networking/openssh.putty.html</a><br />
- <a href="http://help.github.com/troubleshooting-ssh/">http://help.github.com/troubleshooting-ssh/</a><br />
- <a href="http://code.google.com/p/msysgit/issues/detail?id=49">http://code.google.com/p/msysgit/issues/detail?id=49</a></p>
<p>My setup so far is &#8220;Putty Keygen, Putty, Pageant, Git GUI&#8221;</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 128px; width: 1px; height: 1px; overflow: hidden;">http://code.google.com/p/msysgit/issues/detail?id=49</div>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2010/10/04/contents-invalid-public-key-fingerprint-cant-be-blank/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NoMethodError: undefined method `eq&#8217; for nil:NilClass</title>
		<link>http://tamersalama.com/2010/09/27/nomethoderror-undefined-method-eq-for-nilnilclass/</link>
		<comments>http://tamersalama.com/2010/09/27/nomethoderror-undefined-method-eq-for-nilnilclass/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 03:20:27 +0000</pubDate>
		<dc:creator>Tamer</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tamersalama.com/?p=912</guid>
		<description><![CDATA[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 &#8211; this is a must-have if you&#8217;re connecting to oracle using a non-owner username (activerecord-jdbc-adapter). class Model &#60; ActiveRecord::Base set_table_name '&#60;schema&#62;.&#60;table&#62;' end Now &#8211; tracking this down led to lib/arel/engines/sql/relations/table.rb def table_exists? [...]]]></description>
			<content:encoded><![CDATA[<p>JRuby 1.5.2<br />
Rails 3.0<br />
activerecord-jdbc-adapter 0.9.7</p>
<p>This issue arises when setting table name with a schema name prefix. For those in the know &#8211; this is a must-have if you&#8217;re connecting to oracle using a non-owner username (activerecord-jdbc-adapter).</p>
<pre><code>
class Model &lt; ActiveRecord::Base
  set_table_name '&lt;schema&gt;.&lt;table&gt;'
end
</code></pre>
<p>Now &#8211; tracking this down led to<br />
lib/arel/engines/sql/relations/table.rb</p>
<pre><code>
def table_exists?
  @table_exists ||= @@tables.include?(name) || engine.connection.table_exists?(name)
end
</code></pre>
<p>The <code>@@tables</code> include table names as read from the connection (sans schema name). The comparison with the <code>name</code> always yields false resulting in an instantiation of an empty Header (with no attributes). Hence &#8211; <code>alias_table[&lt;attr&gt;]</code> always returned nil and nil.eq is undefined.</p>
<p>Anyways &#8211; as a work around (sorry: non tested monkey patch):</p>
<p>in your apps lib folder (provided that it&#8217;s auto-loaded) &#8211; create the arel_ext.rb</p>
<pre><code>
module Arel
  class Table
    def table_exists?
     #checking with only &lt;table_name&gt; rather than &lt;schema_name&gt;.&lt;table_name&gt;
      @table_exists ||= @@tables.include?(name.to_s.gsub(/.*\./, ''))|| engine.connection.table_exists?(name)
    end
  end
end
</code>
</pre>
<p>Reported on activerecord-jdbc-adapter list: <a target="_blank" href="http://kenai.com/jira/browse/ACTIVERECORD_JDBC-132">http://kenai.com/jira/browse/ACTIVERECORD_JDBC-132</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tamersalama.com/2010/09/27/nomethoderror-undefined-method-eq-for-nilnilclass/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

