I'm trying to generate rows in a HTML table in my view (see below) but:
zone[loc.to_sym]
.... seems to be nil as I keep getting the error :
undefined method `each' for nil:NilClass for this line
gvim
************* Controller ********************
class MainController < ApplicationController
def home
@locations = %w(Africa America Arctic Asia Atlantic Australia
Europe Brazil Canada Chile Indian Mexico Pacific US Misc)
end
****************** View *********************
<% zones = {
US: { 'US/Alaska' => 'Alaska', 'US/Aleutian' =>
'Aleutian', 'US/Arizona'
=> 'Arizona', 'US/Central' => 'Central',
'US/East-Indiana' => 'East
Indiana', 'US/Eastern' => 'Eastern', 'US/Hawaii'
=> 'Hawaii',
'US/Indiana-Starke' => 'Indiana Starke',
'US/Michigan' => 'Michigan',
'US/Mountain' => 'Mountain', 'US/Pacific' =>
'Pacific', 'US/Pacific-New'
=> 'Pacific New', 'US/Samoa' => 'Samoa' },
Miscellaneous: { Cuba:'Cuba', Egypt:'Egypt',
Eire:'Eire',
Greenwich:'Greenwich', Hongkong:'Hongkong',
Iceland:'Iceland',
Iran:'Iran', Israel:'Israel', Jamaica:'Jamaica',
Japan:'Japan',
Kwajalein:'Kwajalein', Libya:'Libya', Navajo:'Navajo',
Poland:'Poland',
Portugal:'Portugal', Singapore:'Singapore',
Turkey:'Turkey', Zulu:'Zulu' }
........ <other regions> ..........
} %>
<% @locations.each do |loc| %>
<tr>
<td align="right"> </td>
<td><select name="<%= loc %>1">
<option value=""
selected="selected"><%= loc %></option>
<% zones[loc.to_sym].each do |key, val| %>
<option value="<%= key %>"><%= val
%></option>
<% end %>
</select>
</td>
<td
align="right"> </td><td></td>
</tr>
<% end %>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/5374D74A.7090001%40gmail.com.
For more options, visit https://groups.google.com/d/optout.