Refactor: remove hard coded formatter in #show_budget_field.
This commit is contained in:
1 parent
a1a66146ee
commit
6dcad41646
1 file changed
+4
-2
@@ -48,9 +48,11 @@ module ContractsHelper
|
|||||||
|
|
||||||
def show_budget_field(object, spent_field, total_field, options={})
|
def show_budget_field(object, spent_field, total_field, options={})
|
||||||
|
|
||||||
|
formatter = options[:format] || :number_to_currency
|
||||||
|
spent_content = send(formatter, object.send(spent_field))
|
||||||
|
total_content = send(formatter, object.send(total_field))
|
||||||
|
|
||||||
show_field(object, spent_field, options.merge(:raw => true)) do
|
show_field(object, spent_field, options.merge(:raw => true)) do
|
||||||
spent_content = number_to_currency(object.send(spent_field))
|
|
||||||
total_content = number_to_currency(object.send(total_field))
|
|
||||||
|
|
||||||
content_tag(:span, h(spent_content), :class => 'spent') +
|
content_tag(:span, h(spent_content), :class => 'spent') +
|
||||||
content_tag(:span, h(total_content), :class => 'budget')
|
content_tag(:span, h(total_content), :class => 'budget')
|
||||||
|
|||||||
Reference in new issue
Block a user