Rails Metal and ActiveRecord Sessions

I was playing around in Rails 2.3 and wanted to mess with Metal for a very simple API. The release notes say that it supports sessions — and that may be true for memcache and cookie stores, but I couldn’t get it working with ActiveRecord.
I sniffed around and noticed that abstract stores aren’t getting loaded [...]

More



Simple rails time based fragment caching with file store

I spent a little while this morning looking around for a rails fragment caching solution which used a file store and had simple expirations built in. No luck. I could just use a memory based cache store, but for this particular problem it was too much overhead to setup and manage.

The features are:

You can [...]

More



Rails 2.2 Custom Error Pages With Exception Loggable

Well, with the release of Rails 2.2 and the ability to create custom error pages I figured I’d revisit my 404/500 pages and try to do it the new way.
Setting up the rescue_from methods were simple enough, but I noticed that when I was capturing my error 500s it wasn’t logging the exception. Here is [...]

More



OSX, RubyGems and cross-thread violations in rb_gc

I recently decided to migrate away from OSX’s default ruby install yesterday and noticed a few quirky hangups. Firstly, for some reason, and I’m not sure if it is just me or not, OSX’s default $PATH variable is putting /usr/local/bin AFTER /bin making your local installs not enabled by default. (Editing the /etc/paths didn’t do [...]

More



Rails: Mocking YAML arrays as ActiveRecord objects

I’ve been finding myself using YAML a lot for silly enums — maybe because I’m lazy, but mostly because there is no need to manage them via a database table. Here is just a simple example — I need to associate a region and division to a client. These will not change much and are [...]

More



Ruby on Rails Helpful Helpers: Content Tags

Another common thing I like to do is use a helper method to handle tricky tag-soupish markup. A client may have 1 URL, in which case I would like to simply display it, but if they have multiple URLs I’d like to put it in a list format. The only problem with using the content_tag [...]

More



Ruby on Rails Helpful Helpers: Defaulting Variables

One piece of code I find myself using a lot is for defaulting values using a simple conditional if statement: condition ? true : false. This isn’t bad in itself, but it also isn’t very powerful and dynamic. I wrote a small application helper which wraps this function and provides a pretty nice way [...]

More



Subversion Info in Ruby / Rails

I was trying to tag a few of my internal apps with a subversion revision number just for personal reference. Since running the command svn info yields YAML-ish output the ruby YAML library can load it. Sweet. The next step was just wrapping it in a class and creating some instance variables and methods for [...]

More



shakebook pro for leopard – switch spaces with violence!

Update!
Switch spaces using your Apple Remote! (Or view the project on GitHub)

I was just goin around on the interblagosphere today and stumbled upon Erling Ellingsen’s smackbook pro. If you’ve never heard of this then you’re in for a shock. The basic idea behind what he has created is a way to switch virtual desktops simply [...]

More