RSpec speed-up (24.6%) by tweaking ruby garbage collection –

We have been tweaking the GC for the Gogobot website, the affects it has are simply mind blowing.

Since I am clearly not happy with the test suite time that we currently have, This seems like a nice solution and I am definitely gonna try it.

RSpec speed-up (24.6%) by tweaking ruby garbage collection –

Where are my engines?

Right now, I am working on an engine for the Gogobot application.

As part of my work on the engine, I am working with the Mongoid gem and the Fabrication gem, both great gems b.t.w.

The problem with Fabrication is that it wasn’t really adapted to working with Engines and it was relying a lot on Rails.root for where to locate the fabricator files.

Since in an engine, the application is located in spec/dummy I needed a better way locate the fabricators.

ok… so far the story of how I got to even writing this post.

To solve my problem I needed to grab all of the engines that are included inside the Rails application.

Turns out, there’s a real easy way to do it.

You can look at my solution including this line in the pull request I have open for Fabrication here:

Working with Resque? perform_later is at 1.0, you should use it

Last night, I released the 1.0 version of perform_later.

Now or later?

The gem is being used in production for over 6 months now, in a big-scale website (Gogobot), so I thought it’s time to put in some extra needed work, some major refactoring and to release 1.0.

What’s new?

  • 1.0 is basically the same in the core functionality, I refactored big bits of the codebase, it’s much cleaner and more readable then before (still need to work quite a bit on code documentation)
  • Added the later method support for ActiveRecord models.
  • Added the loner support, now you can mark methods to be loners, meaning only a single instance of this method can exist in the queue at all times, this is super useful when a user does many actions that will result in say a cache clear for the user, there’s no reason to do a clear more then once. (and there are many more cases like this)

So, right off the README, here’s simple usage for this gem

So, now you can do this:

The best thing about perform_later (not new in this version) is that you can pass in any param, and it will get translated into JSON with no problem.

You can pass in AR objects, hashes, arrays, anything you need, there’s no need to rewrite your methods.

I would love your comments, feel free to contribute issues, pull requests, documentation or anything else.

The simplest Enum you will ever find for your ActiveRecord models

I have been using a really useful snippet for a while now.

While dropping it today into a project I realized just how powerful it is:

  1. it’s a drop-in and will work on any project
  2. it’s database agnostic
  3. it’s dead simple
  4. it’s not sensitive to enum changes
  5. and more and more

Just as an into, an enum is a way to have string represented as integers in your database.


Because integers are much faster to index and query (at least on mysql).

MySQL has an enum solution but ActiveRecord can’t really use it without some nasty hacking and it’s really messy when you want to add another param.

Enough Said, here’s the snippet

This gives you the ability to work with the Account model like so:

As you can see, it’s being persisted into the database as an integer, but you work with symbols/strings which is much nicer and cleaner.

10 Things You Didn’t Know Rails Could do

James Eduard Grey published a presentation of a talk he did in RailsConf.

It is pure gold, so many tips and tricks, I promise you, some of these will be new even to the most experienced of Rails developers.

10 Things You Didn’t Know Rails Could do // Speaker Deck.

Pivotal Tracker Git integration with ease

This post makes 2 assumptions

  1. You are working with Git
  2. You are working with Pivotal Tracker

At Gogobot, we work with Pivotal Tracker (for various reasons).

Pivotal Tracker has very good Git integration, when you commit (and push), the commits can show up as comments to the story.

Another very good thing is that you can change the status of a story just by a commit, you can finish, deliver or anything else you might want.

Usually, you need to add the story id (#12123123) to the commit message yourself, obviously, I never remember to do that.

So, the link in the bottom is a gem that integrates git with Pivotal Tracker very easily and effortlessly.


It has a very good README so keep on reading there.

Run your specs in logical groups

I stumbled upon this StackOverflow question: testing – Organizing rspec 2 tests into ‘unit’ and ‘integration’ categories in rails – Stack Overflow.

Basically, the guy asks how he can run specs isolated into logical groups, running the unit without running the integration and so on.

At Gogobot, we have exactly that, since we run our specs in the CI, we can decide which to run, and they run one after the other and dependent on each other, so if you fail UNIT, the build fails, no need to continue on.

You can run the rakes like so


This is what our spec.rake looks like


14 Ways to Contribute to Open Source without Being a Programming Genius or a Rock Star

Contribution to open source has a myth around it.

People think that “contributing” means changing huge chunks of the code, and being a genius.

It’s actually not the case, documentation for example is a huge contribution to open source, sometimes scratching your own itch with changing a single method is also contribution.

Find something you like and work with every day, and when you encounter a bug, or a need for something, try and implement it.

14 Ways to Contribute to Open Source without Being a Programming Genius or a Rock Star.

Pull Request #5340: Added wrapper tag for simple format, added test by KensoDev · rails/rails

Following my latest post about the simple_format, I think that it’s broken to assume only “p” tags are valid wrappers.

So, I opened a pull request to Rails itself.

Basically, it changes simple_format so you can pass in the wrapper tag you want, I found myself wanting a “div” or a “span” too many times.

Pull Request #5340: Added wrapper tag for simple format, added test by KensoDev · rails/rails.