Skip to content

Commit 98c0348

Browse files
Merge pull request #814 from hiptest/fix-327-concern-cause-app-to-connect-to-db
Prevent getting table info if not connected to db
2 parents 23c04a2 + 6d764da commit 98c0348

File tree

1 file changed

+9
-1
lines changed
  • app/models/devise_token_auth/concerns

1 file changed

+9
-1
lines changed

app/models/devise_token_auth/concerns/user.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ module ClassMethods
9595

9696

9797
def tokens_has_json_column_type?
98-
table_exists? && self.columns_hash['tokens'] && self.columns_hash['tokens'].type.in?([:json, :jsonb])
98+
database_exists? && table_exists? && self.columns_hash['tokens'] && self.columns_hash['tokens'].type.in?([:json, :jsonb])
99+
end
100+
101+
def database_exists?
102+
ActiveRecord::Base.connection
103+
rescue ActiveRecord::NoDatabaseError
104+
false
105+
else
106+
true
99107
end
100108
end
101109

0 commit comments

Comments
 (0)