Format currencies
This commit is contained in:
parent
8bac32bb77
commit
2f8f3404bb
@ -117,6 +117,8 @@ GEM
|
||||
marcel (1.0.4)
|
||||
mini_mime (1.1.5)
|
||||
minitest (5.24.1)
|
||||
money (6.16.0)
|
||||
i18n (>= 0.6.4, <= 2)
|
||||
msgpack (1.7.2)
|
||||
mutex_m (0.2.0)
|
||||
net-imap (0.4.14)
|
||||
@ -252,6 +254,7 @@ DEPENDENCIES
|
||||
debug
|
||||
importmap-rails
|
||||
jbuilder
|
||||
money
|
||||
pg (~> 1.1)
|
||||
puma (>= 5.0)
|
||||
rails (~> 7.1.3, >= 7.1.3.2)
|
||||
|
@ -12,14 +12,14 @@
|
||||
<% @expenses.each do |expense| %>
|
||||
<tr>
|
||||
<td><%= expense.name %></td>
|
||||
<td><%= expense.amount %></td>
|
||||
<td><%= expense.amount.to_currency %></td>
|
||||
<td><%= link_to "Show", expense %></td>
|
||||
<td><%= link_to "Edit", edit_expense_path(expense) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td><%= @expenses.sum(&:amount) %></td>
|
||||
<td><%= @expenses.sum(&:amount).to_currency %></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
5
config/initializers/ruby_extensions.rb
Normal file
5
config/initializers/ruby_extensions.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class Numeric
|
||||
def to_currency
|
||||
Money.from_amount(self, "EUR").format
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user