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 1071577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:43:54+00:00 2026-05-16T20:43:54+00:00

i am using nested_attributes for an association of products back to a transaction. I

  • 0

i am using nested_attributes for an association of products back to a transaction.
I need to add a date to the products model. I would like to add a link to set the date_select to today.

here is the view:

        <% f.fields_for :trans_products do |builder| %>
            <%= render 'trans_product_fields', :f => builder %>
        <% end %>

and the partial:

<tr class="fields">
    <td><%= f.text_field :po, :class => 'prodinfo' %></td>
    <td><%= f.text_field :so, :class => 'prodinfo' %></td>
    <td><%= f.text_field :product, :class => 'prodinfo' %></td>
    <td><%= f.text_field :serial, :class => 'prodinfo' %></td>
    <td class=bigprodinfo><%= f.date_select :pos_date, :include_blank => true, :order => [:month, :day, :year] %>

    <%= link_to_function("today", "set_today('#{????}','pos_date')", :class => "today_link")  %>    </td>
    <td><%= link_to_remove_product "remove", f %></td>          
</tr>

the ???? should read transaction_trans_products_attributes_#number#, #number# shows up correctly for the textfields, the po text field reads id=”transaction_trans_products_attributes_0_po” the next trans_product has id=”transaction_trans_products_attributes_1_po”

how can i get this counter value into my link_to_function parameter?

thx

  • 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-05-16T20:43:55+00:00Added an answer on May 16, 2026 at 8:43 pm

    There should be an iteration_counter automatically set up for your collection (your collection here being called “trans_products”.
    According to the docs, the counter is named after the items in the array eg here it should be called “trans_product_counter”

    For more info, have a look here:
    http://apidock.com/rails/ActionView/Partials

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

Sidebar

Related Questions

So I have model with an association and I'm using a single form with
I'm tring to set values for two models that have a has_one association using
I am using nested Asynchronous callbacks to save my front-end data to the back-end
I'm using nested pages in Jquery Mobile: Looks like this: // wrap page <div
I am using a nested model form to edit all phone numbers of a
I'm using nested_form for a situation where: Parent (climb) ==has_one==> Join Model (route_ascent) ==polymorphic
How do I validate that a model has at least one associated model using
Im using Rails 3.0.3 I have a Model Bill: class Bill < ActiveRecord::Base has_many
i'm using nested_form for adding and deleting nested_attributes. class Text < ActiveRecord::Base attr_accessible :attachments_attributes
When using accepts_nested_attributes_for, instead of having to pass child_attributes, I'd like to pass child.

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.