Just a quick note on Authlogic and naming of the User and Session models.

Generally most people I assume use the name User for the user model and UserSession for the session information. I had this working and then decided the session information would be better described by the name LoginSession instead so went about renaming all the relevent classes/methods etc.

After this change Rails would return an error message of uninitialized constant Login whenever I tried hitting the login page. This is due to Authlogic’s default behaviour of  inferring the user class name from the session model name, in this case, Login from LoginSession.

To get around this use authenticate_with <classname> within your session model to tell Authlogic to authenticate against a different user model. i.e

authenticate_with User

Hopefully this will save someone else the time I spent working out why my app had broken through a simple name change.

Gmail notifier plus on Windows 7

Posted: April 28, 2010 in Windows 7

It might be almost a year since this little app was first released, but it’s not until now that reinstalling everything on my new netbook has prompted me to look for a new Gmail client.

MILES more polished than the official Google application, this little beauty sits pinned in your Windows 7 taskbar displaying a neat unread mail count (after adding to your startup folder to force the load. Did I miss an auto startup option?). Loads of extra functions under menus. Most impressive Windows 7 only app I’ve seen yet.

http://www.neowin.net/news/windows-7-gmail-notifier-application

In my current Ruby n Rails project, the focus of work is to periodically update database entries from XML feeds.

Naturally I’ve implemented a threading system using the rufus-scheduler gem for updating database entries every so many minutes. However I soon noticed that after running on the development enviroment with 1 minute intervals on updates, that the updating of the last updated time column in the db suddenly stopped after about 5 iterations. No error, warnings or other signals (smoke or otherwise).

After a bit of head scratching I finally managed to mentally link the 5 iterations to the pool number setting in the database.yml file. Executing my database updates within the thread job was stopping Rails from cleaning up the unrequired connections (for whatever reason. I suspect this is because the thread is sent back to sleep before this can occur).

So the solution is to simply call the cleanup manually via…

ActiveRecord::Base.connection_pool.clear_stale_cached_connections!

… at the end of every job execution run. Problem sorted!

Earlier I was throwing together a quick and dirty KML parser with the aim of getting some county regions onto a Google Map.

Services were fired off on initialise, loaded up a static KML file, parsed it and passed the Polygons/Polylines back to be placed upon the map. However I was getting a TypeError: Error #1009: Cannot access a property or method of a null object reference from within my parser at the point I was constructing the Polygon or Polyline. Why?!

An hours fist shaking and tea drinking later I discovered that the null it was complaining about was that the Google Map instance had not yet been created (NOT documented behavior). WHY it needs a map instance at all at this point is plain stupid, made even more so by failing to give you a meaningful error message beyond the TypeError 1009.

Lesson here then, if TypeError 1009 is popping up for no reason, check that your Google Map instance hasn’t wondered off.

Adobe AIR Programming Unleashed

Posted: April 29, 2009 in AIR, Books
Tags:

While roaming around Waterstones at the weekend with a mate who attempted to search every shelf for a CSS reference guide (way was this task so difficult?!?!) I came across a new Adobe AIR book by the trio of Stacy Tyler Young, Michael Givens and Dimitrios Gianninas by the name of Adobe AIR Programming Unleashed.

Where I normally find most books to be either too basic or have too few chapters of interest to be worth buying, this one is spot on from the perspective of a Flex developer moving into the world of AIR. No patronising chapters on how to add an event listener, just all the juicy bits about what’s new in AIR (1.5 as well) and how you can go about using them. I was also very surprised to find a section towards the back on FlexUnit testing and even how to go about building tests with ANT scripts. Two thumbs up.

http://www.amazon.co.uk/Adobe-Programming-Unleashed-Stacy-Tyler/dp/0672329719