Skip to content

Instantly share code, notes, and snippets.

@victorcreed
Created February 5, 2014 06:35
Show Gist options
  • Save victorcreed/8818401 to your computer and use it in GitHub Desktop.
Save victorcreed/8818401 to your computer and use it in GitHub Desktop.
generate entries into predefined model
namespace :enriched do
desc "setup settings"
task setup_settings: :environment do
categories = YAML.load_file(File.join(Rails.root, "app", "yamls", "talents", "parent_categories.yml"))
categories["main_categories"].each { |main_category| main_setting, each_loop_method = Setting.create( body: main_category, role_type: "talents" ), lambda { |sub_category| sub_setting = Setting.create(body: sub_category, value: categories[main_category][sub_category]["value"], parent_id: main_setting.id, role_type: "talents")}; categories[main_category]["fields"].each( &each_loop_method ) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment