更新时间:2023-02-27 08:56:44
在 ./db/seeds/my_module.rb
:
module MyModule
puts "In my_module.rb"
# add code here
end
在./db/seeds.rb
中:
require File.expand_path('../seeds/my_module', __FILE__) # the ../ just removes `seeds.rb` filename from the path which is given by __FILE__
p "In seeds.rb"
# add code here