Beginner Error: You have a nil object

So I set out to build an app that is very similar to the Depot app to
build my experience. I added a lot of constant lists for the
pulldowns on the admin add product page. Then this error?

NoMethodError in Admin#new

Showing app/views/admin/_form.rhtml where line #9 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.select

Extracted source (around line #9):

6:
7:

Newused

8: <%=
9: form.select :newused,
10: Vehicle::NEWUSED,
11: :prompt => “New or used vehicle?”
12: %>

from vehicle.rb

NEWUSED = [
[“New”, “New”],
[“Used”, “Used”]
]

On 4/9/07, [email protected] [email protected]
wrote:

You might have expected an instance of Array.
12: %>

The error is related to the ‘form’ variable being nil, not your
NEWUSED constant. So start looking there. Where is form defined?

I don’t, I thought it was universal: form.select and form.text_field
and form.text_area. Hrm. I’m assuming that I missed one of these
guys:

On 4/9/07, [email protected] [email protected]
wrote:

Showing app/views/admin/_form.rhtml where line #9 raised:
9: form.select :newused,

You just added a div field, which certainly doesn’t do anything as far
as Ruby is concerned.

You’re probably missing something like

<% form_for :something, :url => some_url, do |form| %>

Take a closer look at whatever code you’re copying. It’ll show you
exactly what you need to do.

Pat

Ok, I’m getting closer. This gives me the pull-down with NewNew in it
– I need it to be New or Used and not printed twice.

Newused
<%= select 'vehicle_newused','newused', [Vehicle::NEWUSED] %>

On Apr 9, 9:14 pm, “[email protected]

This appears to be the answer, thanks to AgileROR:

Newused
<%= select (:vehicle, :newused, Vehicle::NEWUSED, :prompt => "New or used?") %>

On Apr 9, 9:30 pm, “[email protected]

Ok, you are correct. I found out the problem but that led to another
problem. I’m converted a dynamic scaffold to a static and then edited
the rhtml so that all of the fields wouldn’t be textboxes. In this
case I want a select pulldown and have two options to choose from. I
just removed the form. on each one and now I’ve got a page with the
pulldowns with one option: prompt.