Created
March 15, 2012 14:32
-
-
Save tdouce/2044492 to your computer and use it in GitHub Desktop.
Postal Code not in database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the 2nd project's project_item | |
(rdb:5) p self.project.project_items[1] | |
#<ProjectItem id: 8, project_id: 2, product_id: 67, quantity: 1, unit_price: #<BigDecimal:10bde4cc8,'0.25E2',9(18)>, postal_code_of_manufacture: "29729", params: nil, postal_code_of_fabrication: nil> | |
# Find out how many possible manufacturing locations there are for this project_item | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_m').size | |
7 | |
# Get all the possible manufacturing locations for this project_item | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_m') | |
[#<ProductFeature id: 1837, product_feature_type_id: 19, product_id: 67, text_data: "48117", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1838, product_feature_type_id: 19, product_id: 67, text_data: "75109", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1839, product_feature_type_id: 19, product_id: 67, text_data: "52742", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1840, product_feature_type_id: 19, product_id: 67, text_data: "15025", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1841, product_feature_type_id: 19, product_id: 67, text_data: "14456", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1842, product_feature_type_id: 19, product_id: 67, text_data: "93631", numeric_data: nil, position: 0, query: nil, boolean_data: nil>, #<ProductFeature id: 1843, product_feature_type_id: 19, product_id: 67, text_data: "29729", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) | |
# The project_items' postal code matches the 7th possible manufacture for this project_item | |
(rdb:5) p self.postal_code_of_manufacture | |
"29729" | |
# The manufacture for this project_item is 'l_m_x_7' | |
# Find all the extraction locations for this manufacture and find the extraction_location in the postal_codes table | |
# extraction component #1 | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_1_7') | |
[#<ProductFeature id: 1864, product_feature_type_id: 407, product_id: 67, text_data: "28363", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('28363') | |
#<PostalCode id: 850253, postal_cd: "28363", country_cd: "US", city_name: "MARSTON", state_abbrv: "NC", latitude: #<BigDecimal:10bdc4130,'0.34980128E2',18(27)>, longitude: #<BigDecimal:10bdc4040,'-0.79620281E2',18(27)>> | |
# extraction component #2 | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_2_7') | |
[#<ProductFeature id: 1879, product_feature_type_id: 409, product_id: 67, text_data: "82935", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('82935') | |
#<PostalCode id: 893673, postal_cd: "82935", country_cd: "US", city_name: "GREEN RIVER", state_abbrv: "WY", latitude: #<BigDecimal:10bdc1868,'0.41854493E2',18(27)>, longitude: #<BigDecimal:10bdc1778,'-0.10967476E3',18(27)>> | |
# extraction component #3 | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_3_7') | |
[#<ProductFeature id: 1894, product_feature_type_id: 411, product_id: 67, text_data: "24649", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('24649') | |
#<PostalCode id: 847691, postal_cd: "24649", country_cd: "US", city_name: "SWORDS CREEK", state_abbrv: "VA", latitude: #<BigDecimal:10bdbe910,'0.37082042E2',18(27)>, longitude: #<BigDecimal:10bdbe848,'-0.81911316E2',18(27)>> | |
# extraction component #4 | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_4_7') | |
[#<ProductFeature id: 1909, product_feature_type_id: 413, product_id: 67, text_data: "37723", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('37723') | |
#<PostalCode id: 858465, postal_cd: "37723", country_cd: "US", city_name: "CRAB ORCHARD", state_abbrv: "TN", latitude: #<BigDecimal:10bdbba58,'0.3596233E2',18(27)>, longitude: #<BigDecimal:10bdbb990,'-0.84809525E2',18(27)>> | |
# extraction component #5 | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_5_7') | |
[#<ProductFeature id: 1924, product_feature_type_id: 415, product_id: 67, text_data: "37331", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('37331') | |
#<PostalCode id: 858272, postal_cd: "37331", country_cd: "US", city_name: "ETOWAH", state_abbrv: "TN", latitude: #<BigDecimal:10bdb9000,'0.35331479E2',18(27)>, longitude: #<BigDecimal:10bdb8f10,'-0.8452989E2',18(27) | |
# extraction component #6 ------ RETURNS a nil. postal code is NOT in database ------- | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_e_6_7') | |
[#<ProductFeature id: 1939, product_feature_type_id: 417, product_id: 67, text_data: "26729", numeric_data: nil, position: 0, query: nil, boolean_data: nil>] | |
(rdb:5) PostalCode.find_by_postal_cd('26729') | |
nil | |
---- mysql query ---- | |
mysql> select postal_cd from postal_codes where postal_cd = '26729'; | |
Empty set (0.01 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment