Open ghost opened 11 years ago
Rather that override create!
it seems that this would be a good candidate to utilize the passed in &block
...something like:
active_admin_importable do |model, hash|
object = model.find_by(id: row[:id]) || model.new
model.column_names.each do |key|
key = key.to_sym
if hash.keys.include?(key)
value = hash[key]
object.send "#{key}=", value if value != nil
end
end
object.save ? true : object.errors
end
This started as a response to Issue #5 and ended up including some other features that I find useful for my own projects: