README.md in easy_reference_data-0.1.2 vs README.md in easy_reference_data-1.0.0

- old
+ new

@@ -21,10 +21,11 @@ Place references in 'db/reference/' References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename. Run with: + rake easy:reference_data:refresh ## Deployment Add this line to your application's deploy.rb file: @@ -34,12 +35,19 @@ ## Example The below example ensures that there are 3 users existing in the database after running the 'rake reference_data:load' ### db/reference/000_users.rb - Easy::ReferenceData.refresh User, :system_code, 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com' - Easy::ReferenceData.refresh User, :system_code, 'fred', name: 'Fred Schmitt', email: 'fred.schmitt@mailinator.com' - Easy::ReferenceData.refresh User, :system_code, 'bert', name: 'Bert Symthe', email: 'bert.smythe@mailinator.com' + Easy::ReferenceData.update_or_create User, {system_code: 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com'}, keys: [:system_code] + Easy::ReferenceData.update_or_create User, {system_code: 'fred', name: 'Fred Schmitt', email: 'fred.schmitt@mailinator.com'}, keys: [:system_code] + Easy::ReferenceData.update_or_create User, {system_code: 'bert', name: 'Bert Symthe', email: 'bert.smythe@mailinator.com'}, keys: [:system_code] + +Multiple keys can be used to identify records that would otherwise not have a unique attribute + + ### db/reference/000_prices.rb + Easy::ReferenceData.update_or_create Price, {product_id: 1, type: "Price::RetailPrice", price: 5}, keys: [:product_id, :type] + Easy::ReferenceData.update_or_create Price, {product_id: 1, type: "Price::CostPrice", price: 4}, keys: [:product_id, :type] + Easy::ReferenceData.update_or_create Price, {product_id: 2, type: "Price::RetailPrice", price: 5}, keys: [:product_id, :type] ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`)