vendredi 3 juillet 2015

Limit fields_for to only 1 New Record

I have a form that i want to add comments to a company. but i only want the New form fields to show not the previous one to edit..

I just want the New Empty field... not all the previous comments...

Controller:

  def show
    @company_profile = CompanyProfile.find(params[:id])
    1.times do
      @company_profile.company_notes.build
      @company_profile.dispatchers.build
    end
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @company_profile }
    end
  end

View:

<%= form_for @company_profile, :html => { :class => 'sky-form boxed comments' } do |f| %>
    <fieldset>
      <%= f.fields_for :company_notes do |builder| %>
          <div class="row">
            <div class="col col-md-12">
              <section>
                <label class="input">
                  <%= builder.text_field :notes, :placeholder => "Comment" %>
                  <b class="tooltip tooltip-bottom-right">Enter Comments</b>
                </label>
              </section>
            </div>
          </div>
      <% end %>
    </fieldset>
<% end %>

I just want the new empty field not the 2 others

enter image description here

Aucun commentaire:

Enregistrer un commentaire