Forum: Ruby on Rails passing an object

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Randy B. (Guest)
on 2007-02-09 16:47
I dreated an app called employee using scaffolding. Changed the list
view to incorporate a helper to display date as follows:

<h1>Listing employees</h1>

  <% for column in Employee.list_columns %>
      <th class = "even"><%= column.human_name %></th>
  <% end %>

<% for employee in @employees %>
  <tr class = "<%= cycle("odd","even") %>">
  <% for column in Employee.list_columns %>
<!--    <td><%=h employee.send( %></td> CHANGED TO LINE
        <td><%=h format_date(,employee) %></td>
  <% end %>
    <td><%= link_to 'Show', :action => 'show', :id => employee %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => employee %></td>
    <td><%= link_to 'Destroy', { :action => 'destroy', :id => employee
}, :confirm => 'Are you sure?', :method =>$
<% end %>

<%= link_to 'Previous page', { :page => @employee_pages.current.previous
} if @employee_pages.current.previous %>
<%= link_to 'Next page', { :page => } if %>

<br />

<%= link_to 'New employee', :action => 'new' %>

The helper is in application_helper.rb as follows:

# Methods added to this helper will be available to all templates in the
module ApplicationHelper
        def format_date(col_name,date_object)
                if col_name.include? "date"

Here's the rub, I want to use the helper in the show view (something
like the following):

<% for column in Employee.content_columns %>

<!--  <b><%= column.human_name %>:</b> <%= @employee.send(
%> -->
      <b><%= column.human_name %>:</b> <%= format_date(,
@employee) %>
<% end %>

<%= link_to 'Edit', :action => 'edit', :id => @employee %> |
<%= link_to 'Back', :action => 'list' %>

But, I get this error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.strftime

We've tried eveything that we can think of without success. What gives?

I appreciate your help and any suggestions regarding my problem or
suggestions regarding coding that you would care to make. Learning to
think the way in that Rails (and Ruby) work is certainly turning into an

Thanks again,

This topic is locked and can not be replied to.