Forum: Ruby on Rails auto_link generating error (nil.gsub) in functional test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2b2c2a705ed12f8fb327c7b4c56456c6?d=identicon&s=25 Sean Hussey (seanhussey)
on 2006-01-10 23:11
(Received via mailing list)
Hi everyone,

When running tests, I get this error for running auto_link on a set of
column data:

test_list(PersonnelControllerTest):
ActionView::TemplateError: You have a nil object when you didn't expect
it!
The error occured while evaluating nil.gsub
    On line #28 of app/views/personnel/list.rhtml

    25:   <tr valign="top" class="<%= alternate_rows %>">
    26:   <% display_columns = ["username", "preferred_name", "email",
"title"] %>
    27:   <% display_columns.each do |column| %>
    28:           <td><%= auto_link(person.send(column)) %></td>
    29:         <% end %>
    30:     <td><%= link_to 'Details', :action => 'show', :id => person
%></td>
    31:   </tr>

Only one of the pieces of data ends up with a link (the email), so
this is probably bad design anyway.  How can I handle auto-linking the
email address in this situation?

Thanks,

Sean
This topic is locked and can not be replied to.