Archive for the ‘Ruby on Rails and Software Development’ Category

Using ActiveRecord to connect to Sybase Adaptive Server Anywhere on Windows

Posted by Rahoul Baruah on December 21st, 2009 under General, Ruby on Rails and Software Development Tags: , , , ,  •  Comments Off

Just don’t ask why I know this. Please. It’s making me cry.
Install Ruby using the One Click Installer.
Install the ODBC module (by copying the SO files into the c:\Ruby\1.8\i386-mingw32 folder).
Install the ActiveRecord ODBC adapter (gem install activerecord-odbc-adapter).
Edit C:\Ruby\lib\ruby\gems\1.8\gems\activerecord-odbc-adapter-2.0\ lib\active_record\connection_adapters\odbc_adapter.rb – look for line 1588.
Change the line from elsif dbmsName =~ /SQLAnywhere/i [...]

Moving attachment_fu files from the local filesystem to Amazon S3

Posted by Rahoul Baruah on November 24th, 2009 under Ruby on Rails and Software Development Tags: , ,  •  Comments Off

attachment_fu may not be the in-thing any more but there are still a lot of sites out there using it. And every now and then you realise, far too late, that you should have used S3 instead of the local filesystem.
Switching is easy – just change the :storage parameter to :s3. [...]

Favourite code

Posted by Rahoul Baruah on November 12th, 2009 under Beautiful Code, General, Ruby on Rails and Software Development Tags: , , , , ,  •  Comments Off

I think Bigwig has become my favourite bit of code that I’ve ever worked on.
Before Bigwig, it was Object Factory, before that it was a Delphi class that I used to create tree-structured data (imaginatively called TNode).
Bigwig’s doesn’t have a test suite and it’s not even my code – it was [...]

Posting gems to Rubyforge

Posted by Rahoul Baruah on October 6th, 2009 under General, Ruby on Rails and Software Development  •  3 Comments

Github aren’t building new gems at the moment as they finalise their move to Rackspace. So what do you do if you’ve got a gem that you would like to make available?
Gemcutter’s the new kid on the block – it works as a set of plugins to the gem command that mean [...]

It happens to the best of us

Posted by Rahoul Baruah on October 5th, 2009 under Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code Tags: , , , , , ,  •  Comments Off

We just had some customers report a bug. Not good. We didn’t get an exception email. All the tests passed. We couldn’t see anything untoward in the log files. But it was there. We could reproduce it, both in staging and in production. Not good at all.
But the weirdest thing was we couldn’t [...]

Constructors in Ruby are not guaranteed to be called

Posted by Rahoul Baruah on June 3rd, 2009 under General, Ruby on Rails and Software Development Tags: , ,  •  3 Comments

Today, Caius made a discovery that shocked me.
He had a class, descending from ActiveRecord::Base, with a custom constructor (initialize method). To debug it, he had the constructor raise an exception. In the console, Thingy.new(params) raised the exception as expected. But wotsit.thingies.find_by_field(value) did not. Even though it was instantiating an [...]

Note to self: comparing two branches in git and squashing several commits into one

Posted by Rahoul Baruah on June 2nd, 2009 under General, Managing Successful Projects, Ruby on Rails and Software Development Tags: , , ,  •  3 Comments

I always forget how to do this so I’m writing it down (especially as it’s really easy and git, as usual, makes me feel stupid as Linus is so much smarter than me).
Suppose you’ve been working in branch X and you’re about to merge those changes into branch Y …

work in branch X [...]

My cron jobs and rake tasks won’t write to the Rails log file

Posted by Rahoul Baruah on June 1st, 2009 under General, Ruby on Rails and Software Development Tags: , , ,  •  Comments Off

A project I’ve been working on was recently moved up to Rails 2.2 (Rails 2.3 migration coming soon, but we wanted to take things one step at a time).
All the tests passed. Poking it on the staging server worked well. On to production and all was good.
Time passed. [...]

Using Cucumber to estimate a project

Posted by Rahoul Baruah on May 15th, 2009 under Designing Great Software, Managing Successful Projects, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code Tags: , , , ,  •  Comments Off

Writing estimates up-front is a really tricky part of client work.
From the customer’s point of view it’s pretty essential. You need to know how much you are spending before the work begins so you don’t get stung.
From the developer’s point of view it’s pretty difficult to do because [...]

Switching off transactions for a single spec when using RSpec

Posted by Rahoul Baruah on May 8th, 2009 under Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code Tags: , , , ,  •  Comments Off

I have just written a load of test code that needed to verify that a particular set of classes behaved correctly when a transaction was rolled back.
However, the rest of my suite relied on transactional fixtures (which is Rails’ badly named way of saying that a transaction is started before each test and [...]