2008-03-11

undefined method `last' for {}:Hash - fixed!

Right... I've now spent several days carefully trying to get rid of this error message:
undefined method `last' for {}:Hash
when using Rake in my Rails application. It seems like it's quite a common problem, and some info out there even suggest rewriting some of the code. I tried this, but it didn't work. In the process of finding all this out, I also found out that despite Rails 2 was installed, I was still huffing-and-puffing on with the steamy 1.2.x version. Well, that was easy to solve once my rearmost memory banks had been accessed thanks to a few Google-rounds; in your environment.rb change
RAILS_GEM_VERSION = '1.2.4' unless defined? RAILS_GEM_VERSION
to
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
and you'll be using your new electric Rails.
Then, the next problem I seemed to have was that Rake still refused to run, and it all lead me to figuring out that I've got an old version of the Rails Engines. I just could not get my head around how to upgrade from 1.2.2 to 2.0.0 of the engines.
I tried this:
user@box: $ ./script/plugin install http://svn.rails-engines.org/plugins/engines/
already installed: engines (http://svn.rails-engines.org/plugins/engines/). pass --force to reinstall

To no avail. Andrew was pointing out that "I should use --force" but I'm no Jedi, so I don't tend to use the --force unless I'm really in a pickle. As this was on my staging machine, after a good while, I thought that I should get my funny boots and the light saber and use the --force. Said and done...
user@box: $ ./script/plugin install --force http://svn.rails-engines.org/engines/trunk
+ ./CHANGELOG
+ ./MIT-LICENSE
+ ./README
...
user@box: $ rake
(in /var/www-virtual/myapp/releases/20080307144118)
rake aborted!
Could not locate the following plugins: engines and *

Success! The Hash-error is gone, now all I have to do is to configure my system as explained by Nathaniel Brown (whose Date Time widget I'm also using, thanks!) in Engines 2.0 and Rails 2.0 Upgrade Gotchas.
Checking the engines CHANGELOG file, confirms that I have v.2.0.0. Sweet!
But right now I need lunch.


PS, no I don't have a light saber! I might have a computer in my garage, but I'm not that sad.

1 comment:

Tooony said...

Have a nice lunch! :-P