Created
February 5, 2014 06:35
-
-
Save victorcreed/8818401 to your computer and use it in GitHub Desktop.
generate entries into predefined model
This file contains 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
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