From f723fea4e2638593a46b732d49eb94a9b0b2dff9 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Wed, 30 Oct 2013 23:49:34 +0000 Subject: [PATCH] Load plant parts in db:seed and rake task. --- db/seeds.rb | 24 ++++++++++++++++++++++++ lib/tasks/growstuff.rake | 21 ++++++++++++++++++++- script/deploy-tasks.sh | 2 ++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index c025a0295..d9669c3d5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,6 +9,7 @@ def load_data load_basic_account_types create_cropbot load_crops + load_plant_parts # for development environments only if Rails.env.development? @@ -136,4 +137,27 @@ def load_products ) end +def load_plant_parts + puts "Loading plant parts..." + plant_parts = [ + 'fruit', + 'flower', + 'seed', + 'pod', + 'leaf', + 'stem', + 'bark', + 'bulb', + 'root', + 'tuber', + 'whole plant', + 'other' + ] + plant_parts.each do |pp| + PlantPart.find_or_create_by_name!(pp) + end +end + + + load_data diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index ec552be07..5d14c40c4 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -207,7 +207,26 @@ namespace :growstuff do end end - + desc "October 2013: import initial plant parts" + task :import_plant_parts => :environment do + plant_parts = [ + 'fruit', + 'flower', + 'seed', + 'pod', + 'leaf', + 'stem', + 'bark', + 'bulb', + 'root', + 'tuber', + 'whole plant', + 'other' + ] + plant_parts.each do |pp| + PlantPart.find_or_create_by_name!(pp) + end + end end end diff --git a/script/deploy-tasks.sh b/script/deploy-tasks.sh index d95ea46ef..08dd2b7ac 100755 --- a/script/deploy-tasks.sh +++ b/script/deploy-tasks.sh @@ -16,3 +16,5 @@ rake growstuff:depopulate_null_island echo "2013-10-24 - initialize garden locations" rake growstuff:oneoff:initialize_garden_locations +echo "2013-10-31 - import plant parts" +rake growstuff:oneoff:import_plant_parts