I'm using accepts_nested_attributes_for for my project.


             belongs_to :user
             has_many :holes
             has_many :scores
             accepts_nested_attributes_for :holes

  Hole :
            belongs_to :user
            belongs_to :course
            has_many :beacons
            accepts_nested_attributes_for :beacons


     belongs_to :user
           belongs_to :course
           belongs_to :hole

  def course_params
          params.require(:course).permit(:name, :street, :city, :state,
:zip, :course_role,
                                       :latitude, :longitude,
:course_image, :phone_number,
:fromtheproshop_message, :user_id,

                              :holes_attributes => [:id, :name,
:hole_image, :user_id,

                             :beacons_attributes => [:id,
:smartest_play, :be_aware]

each Course contains 18 holes and each hole have 3 beacons,I need to
edit all in single page shown in image(Ox_alt(1).jpg).In that image if
we assume user clicked on hole-9 then display hole-9's 3 beacons and
edit and submit then after user may want to edit hole 15 or any, then i
need to display that user clicked hole beacons. I've completed with
static hole-id in my logic.
But I.m struck in get user clicked hole beacons dynamically.

views/course/edit.html logic is:

<%= form_for (@course), remote: true do |cb| %>
<div class="course-name1"> <%= cb.text_field :name, class:
"form-control" %></div>
<div id="tabs">
<% (cb.object.holes).each do |i| %>
<div class="hole-one">
<li><h3 class="hole-one-one"><a href="#<%= %>-hole" id="hole-<%= %>" class="hole" ><%= %></a></h3>
<div class="circular circle-green circle-left"></div> </li>
<% end %>

<%= cb.fields_for :holes do |hb| %>
<% if == 19 %> #here give hole-id =19 without this i'll get
all beacons i.e 18*3 edit page
<h3> <%= %></h3>
<%= hb.fields_for :beacons do |bb| %>
<% if == 19 %>
<div class="caddy-tip-label"> <%= bb.label :CaddyTip, class:
"from-shop2" %></div>
<div class="caddy-tip-textarea"> <%= bb.text_area :caddy_tip, class:
"form-control from-shop4", id:"textarea" %></div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>


please give me the solution.