andhapp Random ramblings

Bundler and Rails 2.3.8

Life as a “Rails Developer” is a pretty smooth sailing and Bundler just makes it ever better. Rails 2.3.8 is the newest version from the Rails team. Don’t get me wrong, I love to hack my way through Rails3 but time is a big constraint for the project I am working on at the moment. With Rails3, I am bound to hit some road blocks but this is just a quick project I would like to get done and over with.

I am not going to talk about how to initialise bunder and create a Gemfile. You can follow that easily from the github page. So, for the sake of this post let us assume that this is what your Gemfile looks like:

source :gemcutter

gem "rails",          "2.3.8"
gem "i18n"
gem "formtastic",     "0.9.1"

group :test do
  gem "rspec",        "1.3.0"
  gem "rspec-rails",  "1.3.2"
end

Now, when you run the following command:

bundler install vendor

you will get an error related to ruby_version_check.rb not found or something similar complaining about the absence of ruby_version_check ruby script. To fix it, just create a file named ruby_version_check.rb in your project’s lib folder and copy the contents of this gist in it. I copied this file from the Rails master branch and changed the min_release variable to 1.8.6 since 1.8.7 gave me some nasty segmentation errors on my mac. But if you have 1.8.7 installed and working correctly, change the min_release back to 1.8.7.

Next, step is to add the following code to your environment.rb file:

require "bundler"
Bundler.setup

and you should be good to go.

However, there are two things that I have not yet figured out a solution to:

  1. Using Rails engines like clearance since the generators have been completely revamped in Rails3 and might need a through investigation. So, for now I have added it in the old way using config.gem syntax in the environment.rb file.
  2. I got some strange error on time zone which went away by commenting out config.time_zone = ‘UTC’ line of code. This still needs investigation.

I hope this helps anyone trying to get their head around using Bundler with Rails 2.3.8. This set up might work with pervious versions and if you will try it out for yourself.

Update: Just tried using rspec_controller generator and it can’t be invoked as well. So, using Bundler does not hook up the generators. Although. I would think that should not be the case since Bundler adds all the required libs to the $LOAD_PATH so that they are found when Rails goes looking for them. Needs more investigation.

Quote of the day

An individual who spent hours looking at old skool PHP code:

If Rails is a smart organised businessman then PHP is a homeless bum.

Quote of the day

Taken from StackOverflow podcast #85, and it is beautiful.

Even very smart people have to be in the right place at the right time to be successful. The best success strategy is probably dogged, bullheaded persistence, because there are so many variables that you can’t control or even predict.

Very nice.

Virtues of a Bad Programmer

In contrast to my earlier post.

I am no expert to judge people based on their programming skills. I am a n00b myself. However, I do try and move away from the n00b junction all the time. Anyways, these are the virtues of a bad programmer:

  • Laziness - OMG, who the hell is going to refactor this? Let us just duplicate code all over the shop. I can’t be asked to go over the old code and ensure it can accommodate new business requirements. I will just leave it like this and let someone else worry about it.
  • Impatience - I am not going to google for 2 hours to find a solution to the problem. Neither will I spend time looking through this open source code to fix the issue. Instead, I will cut corners and try and make a business case out of it. I have no patience to upgrade to the latest version since that breaks my existing code and I am not bothered to look through the issues and fix them.
  • Hubris - Clean code? It works man! I do not care if it’s a nightmare for the next guy, my job is to get it to work. It works and that’s what matters.