Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Fix NoMethodError on nil entryable in account activity feed (#1316)

Serge L861a2d2d91fc
diff --git a/app/models/entryable.rb b/app/models/entryable.rb
index cf4d22821f..d7507fe1ba 100644
--- a/app/models/entryable.rb
+++ b/app/models/entryable.rb
@@ -10,7 +10,7 @@ module Entryable
included do
include Enrichable
- has_one :entry, as: :entryable, touch: true
+ has_one :entry, as: :entryable, touch: true, dependent: :destroy
scope :with_entry, -> { joins(:entry) }
diff --git a/app/views/entries/_entry.html.erb b/app/views/entries/_entry.html.erb
index 4bdf42aedd..3c3f83fa34 100644
--- a/app/views/entries/_entry.html.erb
+++ b/app/views/entries/_entry.html.erb
@@ -1,4 +1,6 @@
<%# locals: (entry:, balance_trend: nil, view_ctx: "global") %>
-<%= render partial: entry.entryable.to_partial_path,
- locals: { entry: entry, balance_trend: balance_trend, view_ctx: view_ctx } %>
+<% if entry.entryable.present? %>
+ <%= render partial: entry.entryable.to_partial_path,
+ locals: { entry: entry, balance_trend: balance_trend, view_ctx: view_ctx } %>
+<% end %>
diff --git a/app/views/entries/_split_group.html.erb b/app/views/entries/_split_group.html.erb
index cf182f8be2..978f3d019d 100644
--- a/app/views/entries/_split_group.html.erb
+++ b/app/views/entries/_split_group.html.erb
@@ -2,7 +2,9 @@
<div class="split-group">
<%= render "transactions/split_parent_row", entry: split_group.parent %>
<% split_group.children.each do |child_entry| %>
- <%= render partial: child_entry.entryable.to_partial_path,
- locals: { entry: child_entry, in_split_group: true } %>
+ <% if child_entry.entryable.present? %>
+ <%= render partial: child_entry.entryable.to_partial_path,
+ locals: { entry: child_entry, in_split_group: true } %>
+ <% end %>
<% end %>
</div>