add ability to seed through code
This commit is contained in:
parent
dd5b0ea9e1
commit
f17f299abe
@ -25,3 +25,6 @@ Simple!
|
||||
|
||||
`require 'seed-fu-mongoid/capistrano'` to have your data get re-seeded on deploy.
|
||||
|
||||
### Cucumber/RSpec
|
||||
|
||||
`SeedFuMongoid.seed`
|
||||
|
@ -9,6 +9,18 @@ end
|
||||
|
||||
# punch the duck out of Mongoid::Document
|
||||
|
||||
module SeedFuMongoid
|
||||
class << self
|
||||
def seed
|
||||
Dir['db/fixtures/**/*.rb'].each do |file|
|
||||
puts "== Seed from #{file}"
|
||||
|
||||
load file
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Mongoid::Document
|
||||
module ClassMethods
|
||||
def seed_once(*constraints)
|
||||
|
@ -4,11 +4,7 @@ module SeedFuMongoid
|
||||
namespace :db do
|
||||
desc "Load seed data from db/fixtures"
|
||||
task :seed_fu => :environment do
|
||||
Dir['db/fixtures/**/*.rb'].each do |file|
|
||||
puts "== Seed from #{file}"
|
||||
|
||||
load file
|
||||
end
|
||||
SeedFuMongoid.seed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user