alphagov/trade-tariff-backend — pull request #34 by sauliusg (2012-11-26 09:03:48+00:00)
Title: Fix GoodsNomenclature -> Chapter,Heading,Commodity STI working.

Ruby inheritance with Sequel models work in a weird way that is internal and unlikely to change. The provided STI plugin is not good enough, because it expects record type to be specified in the column and not identified by pattern. The problem:

Before:

```ruby
[1] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[2] pry(main)> Commodity.first
=> #72760, :goods_nomenclature_item_id=>"0101100000", :producline_suffix=>"80", :validity_start_date=>2002-01-01 00:00:00 +0200, :validity_end_date=>2011-12-31 00:00:00 +0200, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[3] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[4] pry(main)> Heading.first
=> #27624, :goods_nomenclature_item_id=>"0101000000", :producline_suffix=>"80", :validity_start_date=>1972-01-01 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[5] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
```

After:

```ruby
[5] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[6] pry(main)> Commodity.first
=> #72760, :goods_nomenclature_item_id=>"0101100000", :producline_suffix=>"80", :validity_start_date=>2002-01-01 00:00:00 +0200, :validity_end_date=>2011-12-31 00:00:00 +0200, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[7] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[8] pry(main)> Heading.first
=> #27624, :goods_nomenclature_item_id=>"0101000000", :producline_suffix=>"80", :validity_start_date=>1972-01-01 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
[9] pry(main)> GoodsNomenclature.first
=> #27623, :goods_nomenclature_item_id=>"0100000000", :producline_suffix=>"80", :validity_start_date=>1971-12-31 00:00:00 +0300, :validity_end_date=>nil, :statistical_indicator=>0, :created_at=>nil, :updated_at=>nil}>
```