module RakeTaskHelpers def seeds @seeds ||= get_seeds end def get_seeds Dir[File.join(Rails.root, 'db','seeds', '*')].reduce({}) do |seeds, seed| load(seed) seed_klass = seed_klass_from_path(seed) seeds[seed_klass.seed_name] = seed_klass seeds end end def verify_seed(seed) abort "Unknown seed #{seed}" unless seeds[seed] end def seed_klass_from_path(path) puts path (path.split("/").last.gsub(/\.rb/,'') + 'Seed').classify.constantize end end