Class: Utils::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/common.rb

Class Method Summary collapse

Class Method Details

.convert_bool(val) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/utils/common.rb', line 4

def self.convert_bool(val)
   ret = val
   if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'sqlite'
     ret = "'t'" if val.to_i > 0
     ret = "'f'" if val.to_i <= 0   
   end
   if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql'
     ret = 1 if val == 't'
     ret = 0 if val == 'f'   
   end

   ret
end