I am developing a webapp (well trying to) in Ruby on Rails.
I have a partial render in my index.html.erb
<%= render :partial => "houses/index", :locals => @houses %>
index.html.erb is loaded when the user hits the root of my domain. This partial cause this error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted Source around line 8
5: <th>Washrooms</th>
6: </tr>
7:
8: <% @houses.each do |house| %>
9: <tr>
10: <td><%=h house.short_desc %></td>
11: <td><%=h house.bedrooms %></td>
Trace of template inclusion: app/views/home/index.html.erb
All I would like to is display 5 houses on my Homepage (index.html.erb)
What am I missing to get this to work?
Many thanks
EDIT:
NoMethodError in Home#index
Showing app/views/houses/_index.html.erb where line #10 raised:
You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each
Extracted source (around line #10):
7: Washrooms 8: 9: 10: <% @houses.each do |house| %> 11: 12: <%=h house.short_desc %> 13: <%=h house.bedrooms %>
Trace of template inclusion: app/views/home/index.html.erb