Reputation: 1021
I have the following code:
UPDATED with correct code:
<div class="field_med" id="ticket_note">
<%= f.fields_for :notes, Note.new do |u| %>
<%= u.text_area :note, :size => "46x4", :placeholder => "Leave notes here. Only Admins can see these." %>
<% end %>
</div>
This has a has_many
association to my Ticket
model so I can append as many notes
as I want.
With the above code, when in my edit view it shows all notes in their own separate textarea that can be editing at the same time.
I'm using the below code to show my preexisting notes in a non-editable format.
<div class="field_med" id="ticket_note">
<% for note in @ticket.notes %><br />
<%= note.created_at %> <%= note.note %>
<% end %>
</div>
How can I just show the latest textarea for a new note, but not display all the preexisting notes?
Upvotes: 0
Views: 129
Reputation: 38645
You could do something like this:
<%= f.fields_for :notes, @ticket.notes.build do |u| %>
Upvotes: 1