Merge pull request #2 from pblesi/master
Use mongoid write_attribute method instead of attribute= method to support dynamic fields
This commit is contained in:
commit
3ed5aa9e10
@ -11,9 +11,13 @@ end
|
|||||||
|
|
||||||
module SeedFuMongoid
|
module SeedFuMongoid
|
||||||
class << self
|
class << self
|
||||||
|
attr_accessor :quiet
|
||||||
|
|
||||||
def seed
|
def seed
|
||||||
Dir['db/fixtures/**/*.rb'].each do |file|
|
files = Dir['db/fixtures/*.rb'].sort
|
||||||
puts "== Seed from #{file}"
|
files += Dir["db/fixtures/#{Rails.env}/*.rb"].sort
|
||||||
|
files.each do |file|
|
||||||
|
puts "== Seed from #{file}" unless quiet
|
||||||
|
|
||||||
load file
|
load file
|
||||||
end
|
end
|
||||||
@ -36,4 +40,3 @@ module Mongoid::Document
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ module SeedFuMongoid
|
|||||||
|
|
||||||
def seed!
|
def seed!
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
document.send :"#{key}=", value
|
document.send :[]=, key, value
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "#{@klass.name} #{document.attributes}"
|
puts "#{@klass.name} #{document.attributes}"
|
||||||
|
Loading…
Reference in New Issue
Block a user