Reputation: 35
I want to render a partial for each offer. I have the following code:
offers/index.html.haml:
- @offers.each do |o|
= render 'offershort', locals: {offer: o}
offers/_offershort.html.haml:
= link_to offer.name, offer_path
= offer.description
I get an error:
undefined local variable or method `offer'
How to do it properly?
Upvotes: 0
Views: 3653
Reputation: 176352
If you use the short version, you need to drop the locals
option
= render 'offershort', offer: o
otherwise
= render partial: 'offershort', locals: { offer: o }
Upvotes: 6