Module: MoneyAttribute::FormBuilderExtension

Defined in:
lib/money_attribute/form_builder_extension.rb

Instance Method Summary collapse

Instance Method Details

#money_amount(method, options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/money_attribute/form_builder_extension.rb', line 13

def money_amount(method, options = {})
  money_from_column = object.public_send(method)
  value = money_from_column ? money_from_column.to_s : nil

  @template.text_field_tag(field_name(method), value,
                           { id: field_id(method) }.merge(options))
end

#money_field(method, options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/money_attribute/form_builder_extension.rb', line 5

def money_field(method, options = {})
  money = object.public_send(method)
  value = money ? money.to_s : nil

  @template.text_field_tag(field_name(method), value,
                           { id: field_id(method) }.merge(options))
end