lib/reform/form/orm.rb in reform-rails-0.2.0.rc2 vs lib/reform/form/orm.rb in reform-rails-0.2.0.rc3
- old
+ new
@@ -17,10 +17,13 @@
record = form.model_for_property(property)
record.send("#{property}=", form.send(property))
@klass = record.class # this is usually done in the super-sucky #setup method.
super(record).tap do |res|
- form.errors.add(property, record.errors.first.last) if record.errors.present?
+ if record.errors.present?
+ error = self.class.name.include?("Mongoid") ? record.errors.first.last : :taken
+ form.errors.add(property, error)
+ end
end
end
end
end