Simple call, weird error

<% @pays.each do |pay| %>

Is giving me an exception:

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occured while evaluating nil.each

I'm lost , pay is the model. Any idead why I'd be getting this error.

<select name="Pay[id]" id="Pay[id]">    <option value="">Pay Types</option>    <% @pays.each do |x| %>       <option value="<%= pay.id %>">          <%= pay.name %>       </option>    <% end %> </select>

Stuart

Hello again :slight_smile:     Urm, okay, stupid question time (first of many no doubt :wink: but.. where are you declaring/instantiating/vivifying @pays ? show the controller code where you are, as well as the wrapping 'lines' (maybe an error with your reseting it or.. something equally crazy :slight_smile:            Regards     Stef

Dark Ambient wrote:

Can you show us the code that assigns to @pays? Notice that it says nil.each, that tells us @pays is nil not each ‘pay’ record because you only ever call their id and name attributes.

You’re also use ‘x’ as your element name, yet trying to reference ‘pay’ – typo?