Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/core_ext/active_record/base.rb
Constant Summary collapse
- SQL =
{ :floor => { 'postgresql' => 'floor(%s::float)', 'mysql' => 'floor(%s)', 'sqlite3' => 'round(%s - 0.5)' } }
Class Method Summary collapse
-
.adapter ⇒ Object
TODO extract this to somewhere else and use Travis.config.env instead.
- .floor(field) ⇒ Object
Class Method Details
.adapter ⇒ Object
TODO extract this to somewhere else and use Travis.config.env instead
17 18 19 20 21 |
# File 'lib/core_ext/active_record/base.rb', line 17 def adapter env = defined?(Rails) ? Rails.env : ENV['RAILS_ENV'] || ENV['ENV'] || 'test' adapter = configurations[env]['adapter'] adapter == 'jdbcpostgresql' ? 'postgresql' : adapter end |
.floor(field) ⇒ Object
12 13 14 |
# File 'lib/core_ext/active_record/base.rb', line 12 def floor(field) SQL[:floor][adapter] % field end |