Skip to content
Browse files

fixing bad and of string

  • Loading branch information...
1 parent fa9aa7f commit 91a2347b01e9d5c1a171f29e562b57bd42a05d3c @onomojo onomojo committed Mar 24, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/client_side_validations/active_record/middleware.rb
View
6 lib/client_side_validations/active_record/middleware.rb
@@ -30,7 +30,11 @@ def self.is_unique?(klass, attribute, value, params)
(params[:scope] || {}).each do |attribute, value|
value = type_cast_value(klass, attribute, value)
- relation = relation.and(t[attribute].eq(value))
+ if relation.is_a?(String)
+ relation = Arel::Nodes::SqlLiteral.new("#{relation} AND #{t[attribute].eq(value).to_sql}")
+ else
+ relation = relation.and(t[attribute].eq(value))
+ end
end
!klass.where(relation).exists?

0 comments on commit 91a2347

Please sign in to comment.
Something went wrong with that request. Please try again.