Edit form problem

I have this form
<%= form_for @lesson do |f| %>
<%= f.label :lesson_name, “Lesson title” %>
<%= f.text_field :lesson_name, class: “form-control” %>
<%= f.label :lesson_icon, “Choise icon” %>
<%= f.select “lesson_icon”, options_for_select([ “ico-03”,
“ico-04”,“ico-05”,“ico-06” ])%>


<%=hh=0%>


<%= f.fields_for :sublessons do |sublesson_a| %>
       <div class="delete-subtitle-<%=hh%>" style="padding-bottom:

25px;">
<%= sublesson_a.label :sublesson_name, “Subtitle 1”
%>
<%= sublesson_a.text_field :sublesson_name, class:
“form-control delete-sublesson-field-#{hh}” %>
<%= sublesson_a.label :sublesson_content, “Content”
%>
<%=sublesson_a.text_area ‘sublesson_content’, rows: 3,
class: “form-control delete-sublesson-content-#{hh}”%>
<%= sublesson_a.label :sublesson_video_link, “Video link”
%>

<%= sublesson_a.text_field :sublesson_video_link, class:
“form-control delete-sublesson-video-#{hh}” %>
Delete
Sublesson

<%= hh=hh+1%>


      <%end%>
     </div>

    <%= f.submit "Submit", class: "btn btn-primary" %>
    <a   class="btn btn-primary" id="addNewTag"

onclick=“add_sublesson()”>Add Sublesson

  <% end %>

This is a form for edit…How can i test if :sublessons is empty?

On Wednesday, August 20, 2014 8:57:49 AM UTC+2, Ruby-Forum.com User
wrote:

       <%= f.fields_for :sublessons do |sublesson_a| %>

class: “form-control delete-sublesson-content-#{hh}”%>

<%end%>

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

I suppose that your lesson ‘has_many’ sublessons. In this case you can
check it as follows:

if @lesson.sublessons.any?

It returns true if the collection is not empty