From 83ed53d245f3dc2a9fce20ff0c0d992643efadf3 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 28 Sep 2018 14:15:42 +0200 Subject: [PATCH] Fixed bug: Re-seed-ing not possible in same process because require_relative loads file only once. --- db/seeds.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 87dbec1e4..edc5e5869 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -14,13 +14,11 @@ Cache.clear # to the matching one of the existing files seeds = %w[settings user_nr_1 signatures roles permissions groups links ticket_state_types ticket_states ticket_priorities ticket_article_types ticket_article_senders macros community_user_resources overviews channels report_profiles chats object_manager_attributes schedulers triggers karma_activities] -# loop and require all seedfiles +# loop over and load all seedfiles # files will get executed automatically seeds.each do |seed| - # we use require relative here since - # - we the seeds file to get loaded only once - # - we want to require it relative to the current path - require_relative "seeds/#{seed}.rb" + # we use load here to be able to re-seed in one process (test env) + load Rails.root.join('db', 'seeds', "#{seed}.rb") end # reset primary key sequences