I have a page on which you create an invoice. There is a separate section that allows you to add payments to invoices. What I want to do is add the ability to create a payment when creating an invoice.
I want to display the VIEW Create Payment form in the VIEW Create Account form. How can i do this? Here is the code:
Type of account form (pay attention to the rendering call):
<%= form_for(@contract) do |f| %> <div class="field"> f.label "Add payment?" <div id="pay_form"> <%= render 'payments/pay_form' %> </div> </div>
(_ pay_form.html.erb) Partially from the payment creation form (a notice that I do not include here in the form_for tag because I do not want the next form inside another form on the invoice page above):
<div class="field"> <%= f.label 'Amount Paid:' %> <%= f.text_field :amount %> </div> <div class="field"> <%= f.label 'Payment Method' %> <%= f.select :method, %w(Cash Credit Check) %> </div>
The main problem is that the variable f does not exist in the partial. And even if I assign Invoice f var from its form, the parameter names will be params[:invoice][:amount] , not params[:payment][:amount] . See what I'm saying?
What is the best way to do this?
source share