This is so simple it shouldnt be an issue but I dont understand whats going on here.
I have the following code
class DashboardController < ApplicationController
def bookings
@bookings = Booking.all
end
end
/views/dashboard/bookings.html.erb
<%= render 'booking', :collection => @bookings %>
/views/dashboard/_booking.html.erb
<%= booking.booking_time %>
I get the following error
undefined method `booking_time' for nil:NilClass
However if I do this in /views/dashboard/_bookings.html.erb
<% @bookings.each do |booking| %>
<%= render 'booking', :booking => booking %>
<% end %>
I get (correct)
2012-12-19 09:00:00 UTC
2012-12-28 03:00:00 UTC
Whats going on here? I really want to use :collection as defined here http://guides.rubyonrails.org/layouts_and_rendering.html