Hi,
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):
36:
37: Feed subscriptions
38:
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 %>
42:
The validation that im applying within my model is:
validates_format_of :Email,
:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i,
: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.