lib/flextures/flextures.rb in flextures-1.0.4 vs lib/flextures/flextures.rb in flextures-1.0.5
- old
+ new
@@ -180,13 +180,13 @@
CSV.open( inpfile ) do |csv|
keys = csv.shift # keyの設定
warning "CSV", attributes, keys
csv.each do |values|
h = values.extend(Extensions::Array).to_hash(keys)
- o = klass.new filter.call h
- # idだけ特別扱いで保存
- o.id = h["id"] if o.respond_to?(:id)
+ filter.call h
+ o = klass.new
+ h.each{ |k,v| o[k]=v }
o.save
end
end
end
@@ -200,11 +200,12 @@
attributes = klass.columns.map &:name
filter = create_filter klass.columns, Factory[table_name]
klass.delete_all
YAML.load(File.open(inpfile)).each do |k,h|
warning "YAML", attributes, h.keys
- o = klass.new filter.call h
- o.id = h["id"] if o.respond_to?(:id)
+ filter.call h
+ o = klass.new
+ h.each{ |k,v| o[k]=v }
o.save
end
end
# 欠けたカラムを検知してメッセージを出しておく