On the left hand side of my page there is a list of documents that the
user has already created. And a form to create/edit documents.
| list of documents| Edit/Create documents|
| | |
| | |
I am trying to do the following
-
Show form for creating a new document when the page first loads.And
on button click reload the page with the updated list and the document
newly created. -
When user clicks on one of the existing documents I want to update
the form to display the details of the document.
I was thinking that partials would be the way to do this.
I have part of (1) done. Now I 'm trying to load the details of the
existing documents.
Any suggestions on how to fix the following error and secondly reload
page when a new document is created.
undefined local variable or method `document’ for
#<#Class:0x007fb10b926c60:0x007fb109fad478>
Extracted source (around line #1):
1: <%= form_for document do |f| %>
2:
3: <%= f.label :name %>
4: <%= f.text_field :name %>
Index.html.erb
<% @documents.each do |document| %>
%>
<% end %>
<%= link_to ‘New Document’, new_document_path %>
<%= form_for document do |f| %>
<%= f.text_field :name %>
<%= f.text_area :notes %>