Last active
September 15, 2015 16:53
-
-
Save smathy/82261d8250974d695281 to your computer and use it in GitHub Desktop.
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
# in seeds/foo.rb | |
class Seeds | |
class Foo | |
def self.call | |
::Foo.create! NAMES.map{|n| { name: n } } | |
end | |
end | |
end |
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
class Seeds | |
NAMES = %w[foo bar wee].freeze | |
def self.call | |
Dir[Rails.root.join 'db/seeds/*.rb'].sort.each do |seed| | |
require seed | |
cls = "Seeds::#{File.basename(seed, '.rb').classify}".constantize | |
cls.() | |
end | |
end | |
end | |
Seed.() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment