Sha256: 1822d4ac69c817e9e5737b57abc04effb36b4abf7670e0cee8b4f6bc84c5e342
Contents?: true
Size: 336 Bytes
Versions: 15
Compression:
Stored size: 336 Bytes
Contents
class Subregion < ActiveRecord::Base belongs_to :region def self.find_by_postcode(postcode) if postcode.strip.upcase =~ /^([A-Z][A-Z]?)/ prefix = '|' + $1 + '|' subregions = Subregion.arel_table Subregion.where(subregions[:postcode_prefix].matches("%#{prefix}%")).first else nil end end end
Version data entries
15 entries across 15 versions & 1 rubygems