Kevin Ansfield
Web Developer
Eastbourne East Sussex

Bio:

Finished college back in 2002 after studying on a Vocational A-Level in ICT and A-Level Photography. After college I went straight into employment at GTech Enterprises where I was the web developer and designer working on numerous client websites and also the in-house e-commerce website for Hip Hop Wardrobe. Along the way I met up with some friends outside of my primary employment who I started to help out with their worldwide Directory website and fledgling hosting service, this business then went from strength to strength and numerous changes in direction until it eventually split into two businesses; RVP, the entrepreneurial partnership/holding company and DigitalBlueprint, a high-end web development and design agency in which I am currently director, shareholder and lead developer.


2 RailsSpace friends
Aure_thumbnail Aurelius Prochazka
Erik_thumbnail Erik Wrenholt

Blog:

1 blog post

Allowing both UK and US PostCodes

As I am based in the UK, one of the first changes I made to the RailsSpace code (in fact I replaced it as I was going through the particular examples) was to allow for both UK and US postcodes in the User model.

This initial change was essentially very simple, although it resulted in a fairly complex custom regex validation in order to fully validate the various forms of postcodes in use in the uk. The final regex validation in my modified RailsSpace currently looks like this:

validates_format_of    :zip_code,
                       :with => /^$|^(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2}$|^\d{5}$|^\d{5}-\d{4}$)/i,
                       :message => "must be a valid zip or post code"

This allows for the entering of UK postcodes, but there is still the issue of getting location searches to work world-wide; I'll cover my attempt at this using GeoKit in a future blog post.

Posted about 1 year ago
Modified about 1 year ago

Default_thumbnail ty_oftrans commented about 1 year ago:

The code displays funnily in my browser - it stretched for 2 miles on the right of the window. Is this my browser or the RailsSpace needs polishing (I'm asking coz I wouldn't like this to happen on my project)? Cheers! Ty


Looking_sideways_thumbnail Kevin Ansfield commented about 1 year ago:

It's just that RailsSpace needs some polishing. Nothing more than a few css classes however.