Skip to content
This repository was archived by the owner on Jul 25, 2025. It is now read-only.

Commit 5e6966d

Browse files
Shpigfordclaude
andcommitted
Fix nil division error in exchange rate calculator
Add proper nil handling for tool.current_rate to prevent TypeError when Synth Finance API fails or returns unsuccessful response 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 681ccc6 commit 5e6966d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/views/tools/widgets/_exchange_rate_calculator.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<img src="https://hatscripts.github.io/circle-flags/flags/<%= tool.to_currency[0..1].downcase %>.svg"
5151
alt="<%= tool.to_currency %>"
5252
class="w-5 h-5 rounded-full inline-block mr-2">
53-
<%= number_to_currency((amount * (tool.current_rate || 0)), unit: tool.to_currency, format: "%n %u") %>
53+
<%= number_to_currency(amount * (tool.current_rate || 0), unit: tool.to_currency, format: "%n %u") %>
5454
</span>
5555
<% end %>
5656
<% end %>
@@ -71,7 +71,7 @@
7171
<img src="https://hatscripts.github.io/circle-flags/flags/<%= tool.from_currency[0..1].downcase %>.svg"
7272
alt="<%= tool.from_currency %>"
7373
class="w-5 h-5 rounded-full inline-block mr-2">
74-
<%= number_to_currency(amount / tool.current_rate, unit: tool.from_currency, format: "%n %u") %>
74+
<%= number_to_currency(tool.current_rate ? (amount / tool.current_rate) : 0, unit: tool.from_currency, format: "%n %u") %>
7575
</span>
7676
<% end %>
7777
<% end %>

0 commit comments

Comments
 (0)