Skip to content

Commit

Permalink
Safely handle when database or table doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Mar 13, 2021
1 parent 816ea44 commit 0cfcebe
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Unreleased

# 1.3.1

* Safely handle choosing coder when database or table doesn't exist - @excid3

# 1.3.0

* Add `has_noticed_notifications` helper for models - @excid3
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
noticed (1.3.0)
noticed (1.3.1)
http (>= 4.0.0)
rails (>= 6.0.0)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: ..
specs:
noticed (1.3.0)
noticed (1.3.1)
http (>= 4.0.0)
rails (>= 6.0.0)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: ..
specs:
noticed (1.3.0)
noticed (1.3.1)
http (>= 4.0.0)
rails (>= 6.0.0)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_master.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ GIT
PATH
remote: ..
specs:
noticed (1.3.0)
noticed (1.3.1)
http (>= 4.0.0)
rails (>= 6.0.0)

Expand Down
4 changes: 4 additions & 0 deletions lib/noticed/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ def mark_as_unread!
end

def noticed_coder
return Noticed::TextCoder unless table_exists?

case attribute_types["params"].type
when :json, :jsonb
Noticed::Coder
else
Noticed::TextCoder
end
rescue ActiveRecord::NoDatabaseError
Noticed::TextCoder
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/noticed/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Noticed
VERSION = "1.3.0"
VERSION = "1.3.1"
end

0 comments on commit 0cfcebe

Please sign in to comment.