Try this refactoring and see if you get the desired result:
index.html.haml
= render 'cars_list', collection: @cars, date: @date
Get @date partial keyword and pass the @date instance @date as a local variable to encapsulate the logic in your scores. I got this moment from Rails Best Practices .
_cars_list.html.haml
%h3 Look at these Cars! %ul %li Something about this car %div = render 'calendars/calendar_stuff', car: car, date: date
As you walked into @cars as collection , this partial will have a reference to a single local variable called car , which can then be passed to the next partial, and now locally date . Since partial visualization is located elsewhere here (more than calendars/ ), the partial keyword is explicitly required here.
_calendar_stuff.html.haml
- if car.date == date %div = car.date
Edit
We recommend moving the collection call to _cars_list.html.haml , but this is not suitable for the problem.
Edit 2
This is the version of the above code, if you still want to specify the local variable as this_car , so you would override the local variable car , which collection automatically generated.
index.html.haml
= render 'cars_list', collection: @cars, as: :this_car, date: @date
_cars_list.html.haml
%h3 Look at these Cars! %ul %li Something about this car %li this_car.description %div = render 'calendars/calendar_stuff', this_car: this_car, date: date
_calendar_stuff.html.haml
- if this_car.date == date %div = this_car.date