Make sure cocoon still works on rails 3.0 (where conditions is not yet supported). Fixes #47.

This commit is contained in:
nathanvda 2012-03-16 20:08:19 +01:00
parent 239790d44c
commit 7bcd2aa98d

View File

@ -81,7 +81,7 @@ module Cocoon
def create_object(f, association) def create_object(f, association)
assoc = f.object.class.reflect_on_association(association) assoc = f.object.class.reflect_on_association(association)
conditions = assoc.conditions.flatten conditions = assoc.respond_to?(:conditions) ? assoc.conditions.flatten : []
new_object = assoc.klass.new(*conditions) new_object = assoc.klass.new(*conditions)
end end