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

<%= 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
<h3> <%= hb.object.name %></h3>
<%= hb.fields_for :beacons do |bb| %>
<% if hb.object.id == 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 %>

Attachments:
http://www.ruby-forum.com/attachment/10571/0x_alt__1_.jpg


-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d62dd0900d227b063501b8c63ed51368%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to