This is my code for rendering the partial (the @parties collection is being generated correctly, I have tested that):
<% @parties.each do |party| %>
<div class="item">
<%= render 'parties/party', :object => party %>
</div>
<% end %>
And this is the code in the partial:
<%= party.name %>
However, I get the following error:
undefined method `name' for nil:NilClass
I’m at my wits end, someone please help 😐
Also, this is the code for the controller to render the view containing the partial (The controller’s called default_controller):
def index
@parties = Party.all
end
Is it of any consequence that this isn’t the parties_controller?
I’ve tried something like below and it worked
and I can access like
party.name. the local variable is named after the partial name which ispartyhere.Note: Im assuming that your both partials are of
parties_controller. So this should work.Update:
Here is what ive tried with again
And its working 🙂