Ruby N. alert. This is a pretty basic question, probably.
I’m tinkering around with putting a Rails app on top of legacy database
tables. Assume that the tables and their structures can not change. The
database type is Oracle, but I don’t think that database connectivity is
a problem, because I can view an individual object via Rails. Going to
http://127.0.0.1:3005/advisories/ZZ yields the following:
Advisory: ZZ
Descr: MISCELLANEOUS ADVISORY
Sort order: 0
Exclusivity: 0
Edit | Back
Okay, great, so, that’s all well and good. However, when I click “Back”
or get rid of the “/ZZ” on the URL, I get the following error:
NoMethodError in Advisories#index
Showing advisories/index.html.erb where line #11 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.each
Extracted source (around line #11):
8:
9:
10:
11: <% for advisory in @advisories %>
12:
13:
14:
(truncated)
Kind of seems like there must be some sort of problem in the
controller’s index method, no? How come it has no problem getting one
particular entry, but listing the entire table’s contents doesn’t work?
Here’s the table structure (notice that since this is a legacy table,
there is no “id” column):
VIEW advisory
Name Null? Type
ADVISORY VARCHAR2(4)
DESCR VARCHAR2(80)
SORT_ORDER NUMBER(3)
EXCLUSIVITY NUMBER(3)
Any ideas? Thanks very much in advance for your help!