Skip to content

Commit

Permalink
Merge pull request lynndylanhurley#814 from hiptest/fix-327-concern-c…
Browse files Browse the repository at this point in the history
…ause-app-to-connect-to-db

Prevent getting table info if not connected to db
  • Loading branch information
booleanbetrayal authored Jan 21, 2017
2 parents 23c04a2 + 6d764da commit 98c0348
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/devise_token_auth/concerns/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ module ClassMethods


def tokens_has_json_column_type?
table_exists? && self.columns_hash['tokens'] && self.columns_hash['tokens'].type.in?([:json, :jsonb])
database_exists? && table_exists? && self.columns_hash['tokens'] && self.columns_hash['tokens'].type.in?([:json, :jsonb])
end

def database_exists?
ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError
false
else
true
end
end

Expand Down

0 comments on commit 98c0348

Please sign in to comment.