I would like to use form_for with a non-activerecord model.
The problem is that the value of the fields is not initialized properly: it is always blank, even if the attribute is present.
For example this works:
@customer = Customer.retrieve_from_api(id)
@customer.billing_address.first_name # => "Marco"
But the form isn't initialized properly:
<%= form_for @customer, as: :customer, url: billing_info_path, method: :put do |f| %>
...
<%= f.fields_for :billing_address do |b| %>
<div class="field">
<%# this is always blank (i.e. the initial value of the field is "") %>
<%= b.text_field :first_name %>
</div>
BTW I know that I could use form_tag, text_field_tag and initialize the value explicitly, but I would like to avoid that and keep the code DRY since I have many fields