class ActiveRecord::Base

Public Class Methods

acts_as_string_length_conformable() click to toggle source
# File lib/string_length_conformable.rb, line 10
    def self.acts_as_string_length_conformable
      if ActiveRecord::Base.connection.adapter_name == 'MySQL'
        validates_with MysqlLengthOfStringValidator
      elsif ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
        validates_with PostgresqlLengthOfStringValidator
      else
        text = <<-TEXT
          Unfortunately #{ActiveRecord::Base.connection.adapter_name} is not supported yet,
          please create an issue https://github.com/Yaponcik/string_length_conformable/issues,
          or pull request!
        TEXT
        raise NotImplementedForDb, text
      end
    end