1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Merge branch 'main' into rule-name

This commit is contained in:
Alex Hatzenbuhler 2025-05-02 00:11:49 -05:00 committed by GitHub
commit d8c7d6aee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 4 deletions

View file

@ -62,8 +62,18 @@ class Account < ApplicationRecord
end
def institution_domain
return nil unless plaid_account&.plaid_item&.institution_url.present?
URI.parse(plaid_account.plaid_item.institution_url).host.gsub(/^www\./, "")
url_string = plaid_account&.plaid_item&.institution_url
return nil unless url_string.present?
begin
uri = URI.parse(url_string)
# Use safe navigation on .host before calling gsub
uri.host&.gsub(/^www\./, "")
rescue URI::InvalidURIError
# Log a warning if the URL is invalid and return nil
Rails.logger.warn("Invalid institution URL encountered for account #{id}: #{url_string}")
nil
end
end
def destroy_later

View file

@ -1,7 +1,25 @@
<%# locals: (transfer:, is_inflow: false) %>
<div class="flex items-center gap-1">
<% first_account, second_account = is_inflow ? [transfer.to_account, transfer.from_account] : [transfer.from_account, transfer.to_account] %>
<%= link_to first_account.name, account_path(first_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
<%# Check if first_account exists before creating link %>
<% if first_account %>
<%= link_to first_account.name, account_path(first_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
<% else %>
<span class="text-warning text-xs italic" title="Transfer ID: <%= transfer.id %>">
Data Error: Missing account
</span>
<% end %>
<%# Use icon helper per conventions %>
<%= icon(is_inflow ? "arrow-left" : "arrow-right", size: "sm") %>
<%= link_to second_account.name, account_path(second_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
<%# Check if second_account exists before creating link %>
<% if second_account %>
<%= link_to second_account.name, account_path(second_account, tab: "activity"), class: "hover:underline", data: { turbo_frame: "_top" } %>
<% else %>
<span class="text-warning text-xs italic" title="Transfer ID: <%= transfer.id %>">
Data Error: Missing account
</span>
<% end %>
</div>