Passing an object

I dreated an app called employee using scaffolding. Changed the list
view to incorporate a helper to display date as follows:

Listing employees

<% for column in Employee.list_columns %> <% end %>

<% for employee in @employees %>

"> <% for column in Employee.list_columns %> <% end %> <% end %>
<%= column.human_name %>
<%=h format_date(,employee) %><%= link_to 'Show', :action => 'show', :id => employee %> <%= link_to 'Edit', :action => 'edit', :id => employee %> <%= link_to 'Destroy', { :action => 'destroy', :id => employee }, :confirm => 'Are you sure?', :method =>$

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

<%= 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> <%= 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs