Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dcollie2 committed Jan 18, 2025
1 parent aa0744c commit cf628a6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/tasks/import_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,17 @@ namespace :import_data do
puts "User #{user.email_address} created"
end
end

desc "Import Topics and their associations"
task topics: :environment do
file_path = Rails.root.join("import_files", "Topics.csv")
data = CSV.read(file_path, headers: true)
data.each do |row|
topic = Topic.find_or_create_by!(name: row["Topic_Name"])
provider = Provider.find_by(name: row["Provider_Name"])
topic.providers << provider
puts "Topic #{topic.name} associated with provider #{provider.name}"
end

end
end

0 comments on commit cf628a6

Please sign in to comment.