Accepts_nested_attributes_for

Hello,

I’m using accepts_nested_attributes_for for my project.

Models

Course:
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

Beacon:

 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,
:restaurant_phone_number,
:restaurant_menu_file,
:welcome_message,
:fromtheproshop_message, :user_id,
:fromtheclubhouse_message,
:aroundtheclub_message,

                          :holes_attributes => [:id, :name,

:hole_image, :user_id,

                         :beacons_attributes => [:id,

:name,:user_id,
:caddy_tip,
:smartest_play, :be_aware]
])
end

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| %>

<%= cb.text_field :name, class: "form-control" %>
    <% (cb.object.holes).each do |i| %> <% end %>

<%= cb.fields_for :holes do |hb| %>
<% if hb.object.id == 19 %> #here give hole-id =19 without this i’ll get
all beacons i.e 18*3 edit page

<%= hb.object.name %>

<%= hb.fields_for :beacons do |bb| %> <% if hb.object.id == 19 %>
<%= bb.label :CaddyTip, class: "from-shop2" %>
<%= bb.text_area :caddy_tip, class: "form-control from-shop4", id:"textarea" %>
<% end %> <% end %> <% end %> <% end %> <% end %>

please give me the solution.