Ruby on Rails Saturday, March 30, 2013

On 30 March 2013 20:59, Jay notReq <lists@ruby-forum.com> wrote:
> 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.

I would ask one question at a time, otherwise the thread will get side
tracked. First fix the error.

>
> 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
> ...
> <%= link_to 'New Document', new_document_path %>
> </div>
> <div id="docEdit">
> <%= render :partial => "form", :locals => { :document =>
> Document.new } %>

Are you sure you have not got another call to the form partial
somewhere else, and have forgotten the locals specification there?

If not then have a look at the Rails Guide on debugging which will
show you techniques that you can use to debug the code.

Colin

> ...
> _form.html.erb
>
> <%= form_for document do |f| %>

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