Rails Hash Ordering

My expectation was that when I create a hash it’s going to act like a queue and be sorted in the order in which I inserted things. As I found out today, that is definitely not the case.

There is a very easy way that Rails offers to give a hash this behavior and it’s the OrderedHash function found in the ActiveSupport libraries.

my_hash = ActiveSupport::OrderedHash.new

After that initialization, your hash will be maintained in the order you insert things. Something to watch out for.

A couple of Ruby on Rails v1.2 gotchas

I recently upgraded a few projects to Rails v.1.2 and had a couple of issues arise.

Disappearing objects when dropped using drag and drop in Safari

For one project I use the drag and drop re-ordering provided by the Scriptaculous library. Not sure what did it, possibly even a Safari update, but only in Safari, once you let go of a dragged object, that object would disappear. It would come back when you refreshed the page and would have successfully triggered its intended action.

I did update my javascript files upon upgrading to v.1.2.1, but had not upon the upgrade to v1.2.2 since I wasn’t aware of any changes. I think the release of Scriptaculous on its actual site is newer (v1.7 right now) than that included in Rails so I updated my scripts and that solved the problem.

Model attributes not in the database were inaccessible

I wasn’t able to figure this one out, but was able to get around it. I have a model which has some methods to send/receive messages to a device. I had a

attr_accessor :last_response

which is an attribute that’s not in the database. It was simple a place to temporarily store the full message of the last response for use later on in the code. After the upgrade to v1.2.1 things were fine. However after updating to v.1.2.2, I started getting “Method not defined” errors. It seems like other people have hit this one, too.

My solution was simply to remove the property and change it to @last_response which worked for my limited use of it.

I’m still scratching my head though, since similar attributes work fine in other classes. The problem class, however, is unique in that instead of having ActiveRecord:Base as its parent, the actual parent is a generic class whose parent is ActiveRecord:Base.

Vista Home Premium and a New Gaming PC

I couldn’t wait so I got all the bits and pieces for a new gaming PC and they all arrived the end of last week. It actually went together quicker than I thought it would, so I was left trying to decide if I wanted XP or Vista on it. Considering I have an MSDN subscription with Microsoft and have licenses for Vista already, I decided to download the latest ISO images and install the Home Premium version.

It seems fine now, but here are some of the issues I’ve run into:

Vista would not install on an unformatted disk

I kept getting an exception error when the installer was trying to load. Some research indicated that a lot of people have run into the same thing. In some cases it was a bad DVD or CD burn, but in others, the solution was to run through the Windows XP install far enough to format the hard drive. So after doing a base install of XP Home, I booted up with the Vista DVD I created and the installation process went through.

Video Drivers

nVidia’s drivers for Vista are still in beta, so I had to download those to get the full benefits of my new graphics card. It’s unknown whether or not the drivers will be out of beta when Vista hits the stores. I have seen what I’ll call weird video events when the screen switches modes for games and sometimes when launching apps, so it’s not quite finished baking yet.

I Allow…

Uggghhh. I’m already tired of getting asked to Deny/Allow any little thing that happens. I can understand it from a security standpoint, but having experienced similar permission prompts on Mac and Linux, Vista’s prompts seem excessive.

World of Warcraft Updates

I’ve been able to install a few games, Doom 3, Half-Life 2 Eps. 1 and World of Warcraft. All are working great. However, I did run into one issue patching World of Warcraft, but was able to quickly find a solution on their forums. One of the patches (not all of them) would bomb out at the end and not get applied. It made a change to the Start Menu links for the game which Vista did not like and since Vista didn’t prompt me to allow it, the patch would not install. The solution was to manually apply the patch by right clicking the patch executable and selecting “Run as administrator”.


Everything else seems to be fine but I’m not doing anything but playing games so far. This won’t be a development machine, but I can at least use it for IE7 testing since I still want to keep IE6 on my work notebook as long as possible for easier testing.

function MM_preloadImages

Does anyone else get depressed when they view source on a web page and find this function?

More Articles

Page 5 of 10 » ‹ First  < 3 4 5 6 7 >  Last ›