Use mongoid write_attribute method instead of attribute= method to support dynamic fields #2

Merged
pblesi merged 2 commits from master into master 2014-06-06 14:50:11 +00:00
2 changed files with 7 additions and 4 deletions

View File

@ -11,9 +11,13 @@ end
module SeedFuMongoid
class << self
attr_accessor :quiet
def seed
Dir['db/fixtures/**/*.rb'].each do |file|
puts "== Seed from #{file}"
files = Dir['db/fixtures/*.rb'].sort
files += Dir["db/fixtures/#{Rails.env}/*.rb"].sort
files.each do |file|
puts "== Seed from #{file}" unless quiet
load file
end
@ -36,4 +40,3 @@ module Mongoid::Document
end
end
end

View File

@ -71,7 +71,7 @@ module SeedFuMongoid
def seed!
data.each do |key, value|
document.send :"#{key}=", value
document.send :[]=, key, value
end
puts "#{@klass.name} #{document.attributes}"