Skip to content

Commit

Permalink
Fixed deprecation warning with Active Record 6.1 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jan 15, 2021
1 parent 95fb172 commit a164cb2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.1 (unreleased)

- Fixed deprecation warning with Active Record 6.1

## 3.1.0 (2020-12-04)

- Added `instance` method
Expand Down
16 changes: 12 additions & 4 deletions lib/generators/ahoy/activerecord_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def copy_templates
end

def properties_type
# use connection_config instead of connection.adapter
# so database connection isn't needed
case ActiveRecord::Base.connection_config[:adapter].to_s
case adapter
when /postg/i # postgres, postgis
"jsonb"
when /mysql/i
Expand All @@ -29,8 +27,18 @@ def properties_type
end
end

# use connection_config instead of connection.adapter
# so database connection isn't needed
def adapter
if ActiveRecord::VERSION::STRING.to_f >= 6.1
ActiveRecord::Base.connection_db_config.adapter.to_s
else
ActiveRecord::Base.connection_config[:adapter].to_s
end
end

def rails52?
ActiveRecord::VERSION::STRING >= "5.2"
ActiveRecord::VERSION::STRING.to_f >= 5.2
end

def migration_version
Expand Down

0 comments on commit a164cb2

Please sign in to comment.