I'm trying to create a data entry form but getting an error when it
sumbmits. I am using an hash to get the names of the fields definied
in the controller's "new" function:
def new
@thing = thing.new
@columns = Hash.new
@columns['thing_general'] = [
["title","name"],
["number","num"],
etc...
and then I access it in the object's new.html.erb:
<% for c in @columns['thing_general'] do %>
<tr>
<td class="name">
<label for="<%=c.first%>"><%=c.first%></label></td>
<td>
<input id="<%=c.second%>" name="thing[<%=c.second
%>]"type="text" /></td>
</td>
the first time I load the page, the correct form displays but then
when I click submit, I get this error :
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
Extracted source (around line #38):
35: <tr><td><hr/></td></tr>
36:
37: <tbody>
38: <% for c in @columns['thing_general'] do %>
39: <tr>
40: <td class="name">
41: <label for="<%=c.first%>"><%=c.first%></label></td>
why would it get a nil object when I submit the form (after working
the first time) and why is it trying to load the same page after
submitting?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.