Ruby on Rails Saturday, March 30, 2013

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

1) 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.

2) 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: <div class="field">
3: <%= f.label :name %><br />
4: <%= f.text_field :name %>
Index.html.erb

<div id="docList">
<%= search_field(:user, :document) %>

<% @documents.each do |document| %>
<li><%= link_to document.name, edit_document_path(document.id)
%></li>
<% end %>
<br />

<%= link_to 'New Document', new_document_path %>
</div>
<div id="docEdit">
<%= render :partial => "form", :locals => { :document =>
Document.new } %>
</div>
_form.html.erb

<%= form_for document do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :notes %><br />
<%= f.text_area :notes %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment