Subscribe to RSS Feed

Posts Tagged ‘ Ruby On Rails ’

Annual C.V. Update

August 18, 2010 by Dan Garland

I couldn’t defer it any longer, so its time I held my annual C.V. update. This year, I’ve been doing more web-agency work with Head London, working on a grocery website, a classroom presentation tool and a celebrity competitions website. I also worked on the redesign of the TouchLocal website and its sister project Wefinda.

Take a look at the latest C.V. on my cv page.

Continue Reading »
No Comments

I’m currently bug-fixing on a Rails project, and encountered the need to convert the default UTC date-formats into local times, seeing as we’re enjoying our extra hour in our glorious British summer time. The documentation is a little confusing on this point, but I found that a good solution is to keep UTC for use in the database, and to just convert the string representation in the front-end:
<%= some_model.created_at.in_time_zone(‘London’).to_s(:short) %>

This would be good enough to work with sorting, and finds too, provided you were a little careful about which date representation you were using. There is also the ability to change the timezone with Time.zone = “London”.

Continue Reading »
No Comments
Boosting the Hubbub of local shops

Hubbub is a new deliveries service that rounds up notable local shops and provides a single shop-front for them all, allowing customers to pick from the best grub in their borough. Selected for their repute, their ethical standards and their quality, the Hubbub shops collectively offer an alternative to the homogenised offerings of the cartel supermarkets, bringing their individual flavour to their community over the web.

With a butcher, a baker, a and greengrocer in Hubbub’s first catchment area, it is feasible to get your week’s shopping on Hubbub, yet the up-market range of cakes, wines and chocolates means hosting your fancy dinner party won’t be tarnished by ‘taste the difference’ wrappers.

Currently, the site delivers only to Islington, London, with plans to expand to other London boroughs. The site is scoped entirely around these delivery zones, which determines what products and stores are displayed. One technical challenge of the site is ensuring that customers, stores, products, deliveries, refunds, orders and shopping baskets don’t drift from Islington to Fulham. (If you wish to try-out the website, try putting in the example postcode provided). Rails helps out by using nested routes to allow us to scope resources within an area, so that our URLs are always prefixed ‘in-your-area/:id’.

But this was no straightforward e-commerce shopping site. Partly down to the ambitious nature of the developers at Head London when planning the project, the site is a full-blown delivery management system that runs the entire Hubbub business, which is a genuine on-line company. The site has to be aware of what deliveries the Hubbub drivers are available to make, and track customer’s shopping baskets on the website to the delivery slots. These slots equate to hours in the day of the customer’s choosing, when they would like their goods to be delivered, and each have a capacity. So the checkout process has to be integrated with this system, to ensure that Hubbub can fulfil the orders the website is taking.

Hubbub also has a sophisticated payment mechanism, beyond the scope of most normal payment-processing use cases. Due to the nature of selling locally-sourced produce, some items may fluctuate in price from the point they are ordered to when they are delivered; items sold by weight such as meat and cheese may vary, especially when whole items are needed, such as a 1 kilogram chicken might actually vary depending on the individual bird. This plays havoc when coding a quantity, price and order total system, of which Hubbub has an elaborate variety of options for the administrators populating the database. To support this change in price, we take a nominal amount to verify the card, refund it and then process the order, which may have radically altered afterwards, some time after. Using SecureTrading and XPay, we were able to realise these special use cases, without compromising on security, and without storing sensitive credit card information. We built an open-source rails gem called breadmachine, which is capable of handing 3D-secure redirects and standard authorisations transparently.

Joining an in-progress project of this size was quite daunting. Given a use case or issue ticket, to comb through fifty model classes and determine what to change made for a steep learning curve. The complex object graph of Hubbub meant that making insular changes was difficult; sometimes a feature ran through the entire system meaning that sufficient tests for regression became an immediate need. We ditched the fixtures, which were becoming unmanageable, with NotaHat’s Machinist to mock the objects, trading the relative ease of object instantiation against an increased test suite running time.

Hubbub enters a busy and unproven, yet growing market of on-line groceries. Some have their doubts, but I think that this market has huge potential. When the quality of locally-sourced produce is considered, as well the environmental benefits, its easy to see on-line groceries go the way of the mobile applications market – initially an expensive and questionable area but eventually viable and sustainable.

Continue Reading »
No Comments

In my current Ruby on Rails project, I’m learning about Notahat’s machinist testing framework to build object graphs on which to write unit tests. Its a nice improvement on fixtures; using an object-orientated, programmatic approach to creating test data.

In the pursuit of 100% code coverage, I hit on a problem when trying to test UploadColumn, which was being used for handling images on a Product class. Normally in a Test::Unit class, I could invoke the fixture_file_upload method to simulate the multi-part form upload of an image, but in machinist I couldn’t do that. After finding next to nothing in the way of documentation for testing Upload column, I did some rummaging around in the gem and found the solution.

At the top of your blueprints file, include UploadColumn:
include UploadColumn
Then, in your blueprint, you can use the UploadedImage class to represent your uploaded image:
Product.blueprint do
title
description
image { UploadedFile.upload(File.new(RAILS_ROOT + ‘/test/fixtures/label.png’)) }
end
I hope that helps somebody…

Continue Reading »
No Comments

Win at Westfield

September 16, 2009 by Dan Garland

I today completed a twelve-day stint working with Westfield London in collaboration with Delete London, working on Ruby on Rails development.

The very lovely digital marketing team had some ideas for quick wins to improve the user experience on the London Westfield website, including adding affiliate product data to the retailer pages, and creating an events booking system. I was brought in to help realise these ideas, and turned around two rapid solutions in the allotted time.
Affiliates
The challenge was to find a way to manage the variety of retailer and affiliate partners that Westfield deal with, in an efficient way. I developed an XML parser using REXML’s stream listener to read XML information from an arbitrary affiliate partner, and create product objects from the live stream. These objects then interface with the existing CMS system and generate XML documents ready to be picked-up in the view. Not only does this vastly improve the look of the retailer pages and raise the profile of their clients, but their click-throughs will earn affiliate fees. Win!
Events
Responding to a very tight deadline, I developed an events booking system, designed for the digital marketing team to administer events with minimal effort. The system, implemented in two days, has an administrative back-end that allows the creation of events, with multiple dates attached, composed in an AJAX-form. I used unobtrusive_date_picker to render a user-friendly date picker, as well as restful_authentication to handle the login process. In order to launch within the timeframe, we decided to build the system as a stand-alone webapp, which was supposed to be hosted on a third-party, but after an eleventh-hour issue, I ended up offering my own server as a host, and therefore have my first corporate client! However, the rendered form sits within an IFRAME to hide the URL from the customer.

Meanwhile, hundreds are signing up to Westfield’s events, and the marketing team can download their required CSV data on demand, and the form will deactivate once individual dates become full.

If you’re into fashion, you should sign-up! http://uk.westfield.com/london/offers-events/events/william-baker-booking

Continue Reading »
No Comments