Rails validation - newbie


Im getting the following error while attempting to apply valdiation to
email addresses on a form in my rails app:

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

Extracted source (around line #39):

37: Feed subscriptions

39: <% @feeds.each do |feed| %>
40: <option value="<%= feed.id %>" <% if
(@user.subscriptions.find(:all, :conditions => “FeedIdentity =
#{feed.id}”).length != 0) %>selected=“selected”<% end %>><%= feed.Title
41: <% end %>

The validation that im applying within my model is:

validates_format_of :Email,
:with =>
:on => :update,
:message => ‘has an invalid format’

This is the first time ive tried to use validation on fields hence I may
well be missing something really simple here.

From the error, I would guess that the @feeds variable is nil. It would
helpful to see the corresponding controller, and know the url you
entered to
trigger the error. My guess is that in some scenario, the @feeds is not
being set in the controller.