Improved error handling.

This commit is contained in:
Martin Edenhofer 2013-10-01 08:17:01 +02:00
parent e6fcd3c359
commit 9af5867b6f

View file

@ -89,8 +89,12 @@ returns
self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0,assoc.name.to_s.length-1] + '_ids'
if params.has_key?( real_key.to_sym )
list_of_items = params[ real_key.to_sym ]
if params[ real_key.to_sym ].class != Array
list_of_items = [ params[ real_key.to_sym ] ]
end
list = []
params[ real_key.to_sym ].each {|item|
list_of_items.each {|item|
list.push( assoc.klass.find(item) )
}
self.send( assoc.name.to_s + '=', list )