Skip to content

Instantly share code, notes, and snippets.

@smathy
Last active September 15, 2015 16:53
Show Gist options
  • Save smathy/82261d8250974d695281 to your computer and use it in GitHub Desktop.
Save smathy/82261d8250974d695281 to your computer and use it in GitHub Desktop.
# in seeds/foo.rb
class Seeds
class Foo
def self.call
::Foo.create! NAMES.map{|n| { name: n } }
end
end
end
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