Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8319739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:25:06+00:00 2026-06-08T22:25:06+00:00

I have a page in which you create an invoice. There is a separate

  • 0

I have a page in which you create an invoice. There is a separate section that allows you to add payments to invoices. What I’m wanting to do is add the ability to create a payment when creating an invoice.

I’m wanting to render the “Create Payment” form VIEW into the “Create Invoice” form VIEW. How can I do this? Here is some code:

Invoice Form view (notice the render 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) The partial from the create payment form (notice I’m not including the form_for tag here because I don’t want to next a form inside of 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 the f variable in the partial doesn’t exist. And even if I assign the Invoice’s f var from it’s form, the names of the params would be params[:invoice][:amount] rather than params[:payment][:amount]. See what I’m saying?

What’s the best way to go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:25:08+00:00Added an answer on June 8, 2026 at 10:25 pm

    You need to pass the f variable from the view to the partial.

    To do this, change

    <%= render 'payments/pay_form' %>
    

    into

    <%= render 'payments/pay_form', f: f %>
    

    Should you encounter name errors, since both are named f

    try:

    <%= render :partial => 'payments/pay_form', :locals => { :f => f} %>
    

    or

    <%= form_for(@contract) do |builder| %>
      <div class="field">
        builder.label "Add payment?"
        <div id="pay_form">
          <%= render 'payments/pay_form', f: builder %>
        </div>
    </div>
    

    Hope this helps.

    For further learning, I think what you are really looking for is nested forms.

    Here are some good tutorials on this subject, if you are interesting in learning about them:

    http://railscasts.com/episodes/196-nested-model-form-part-1
    http://railscasts.com/episodes/197-nested-model-form-part-2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which basically allows an admin user to create manager user
I have designed an ASP.NET page which create graphs. I have written a class
I have the requirement to create a page which contains a graph at the
I have a UINavigationController (to use like a wizard page) which I create programmatically
Here I am working with facebook application. I have create page which are working
hi I have page which is action create for order. I want to be
I have a page which contains an overridable property FileName. I want to create
I have a page in which I create dynamic controls via OnInit. On the
Is there any way to disable jqgrid local cache??? I have a page which
I have written jsp page in which i create String with gb2312 charset, Then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.