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
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 %>

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

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

<%= link_to 'New Document', new_document_path %>
<div id="docEdit">
<%= render :partial => "form", :locals => { :document => } %>

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

Posted via

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
To post to this group, send email to
For more options, visit

No comments:

Post a Comment