Flowdock
method

build_relation

Importance_0
v3.2.8 - Show latest stable - 0 notes - Class: ActiveRecord::Validations::UniquenessValidator
build_relation(klass, table, attribute, value) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/validations/uniqueness.rb, line 55
      def build_relation(klass, table, attribute, value) #:nodoc:
        column = klass.columns_hash[attribute.to_s]
        value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if value && column.text?

        if !options[:case_sensitive] && value && column.text?
          # will use SQL LOWER function before comparison, unless it detects a case insensitive collation
          relation = klass.connection.case_insensitive_comparison(table, attribute, column, value)
        else
          value    = klass.connection.case_sensitive_modifier(value) if value
          relation = table[attribute].eq(value)
        end

        relation
      end
Register or log in to add new notes.