且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将seeds.rb 分成多个部分?

更新时间: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