Format currencies
This commit is contained in:
parent
8bac32bb77
commit
2f8f3404bb
1
Gemfile
1
Gemfile
@ -61,3 +61,4 @@ group :development do
|
|||||||
# gem "spring"
|
# gem "spring"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
gem "money"
|
@ -117,6 +117,8 @@ GEM
|
|||||||
marcel (1.0.4)
|
marcel (1.0.4)
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
minitest (5.24.1)
|
minitest (5.24.1)
|
||||||
|
money (6.16.0)
|
||||||
|
i18n (>= 0.6.4, <= 2)
|
||||||
msgpack (1.7.2)
|
msgpack (1.7.2)
|
||||||
mutex_m (0.2.0)
|
mutex_m (0.2.0)
|
||||||
net-imap (0.4.14)
|
net-imap (0.4.14)
|
||||||
@ -252,6 +254,7 @@ DEPENDENCIES
|
|||||||
debug
|
debug
|
||||||
importmap-rails
|
importmap-rails
|
||||||
jbuilder
|
jbuilder
|
||||||
|
money
|
||||||
pg (~> 1.1)
|
pg (~> 1.1)
|
||||||
puma (>= 5.0)
|
puma (>= 5.0)
|
||||||
rails (~> 7.1.3, >= 7.1.3.2)
|
rails (~> 7.1.3, >= 7.1.3.2)
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
<% @expenses.each do |expense| %>
|
<% @expenses.each do |expense| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= expense.name %></td>
|
<td><%= expense.name %></td>
|
||||||
<td><%= expense.amount %></td>
|
<td><%= expense.amount.to_currency %></td>
|
||||||
<td><%= link_to "Show", expense %></td>
|
<td><%= link_to "Show", expense %></td>
|
||||||
<td><%= link_to "Edit", edit_expense_path(expense) %></td>
|
<td><%= link_to "Edit", edit_expense_path(expense) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Total</td>
|
<td>Total</td>
|
||||||
<td><%= @expenses.sum(&:amount) %></td>
|
<td><%= @expenses.sum(&:amount).to_currency %></td>
|
||||||
<td colspan="2"></td>
|
<td colspan="2"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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