Guest User

Untitled

a guest
Apr 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? }
  2.  
  3. results = connection.select_all(
  4. construct_finder_sql(
  5. :select => "#{finder_class.quoted_table_name}.#{attr_name}",
  6. :from => "#{finder_class.quoted_table_name}",
  7. :conditions => [condition_sql, *condition_params]
  8. )
  9. )
  10.  
  11. unless results.length.zero?
  12. found = true
  13.  
  14. if configuration[:case_sensitive] && finder_class.columns_hash[attr_name.to_s].text?
  15. found = c.any? { |a| a[attr_name.to_s] == value }
  16. end
  17.  
  18. record.errors.add(attr_name, configuration[:message]) if found
  19. end
Add Comment
Please, Sign In to add comment