Skip to content

Commit

Permalink
fix(UniquenessValidator): fill record's scope fields if they exist on…
Browse files Browse the repository at this point in the history
… form
  • Loading branch information
DemidenkoAndrey committed Jul 21, 2017
1 parent cb48fc6 commit 211c82a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/reform/form/orm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def validate(form)
record = form.model_for_property(property)
record.send("#{property}=", form.send(property))

scopes = *options[:scope]
scopes.each do |scope|
record.send("#{scope}=", form.send(scope)) if form.respond_to?(scope)
end



@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?
Expand Down

0 comments on commit 211c82a

Please sign in to comment.