first of all, excuse me if my english is not always very good.
I have a problem with the each_with_index... When I show a project, I display the offers for this project. I have to make appear a banner in third position of offers, so I use each_with_index for that.
The problem is that: if I have sixteen offers on a project, I have sixteen times the entirely list of offers, and I don't know why.
This is my code:
- @offers.each_with_index do |offer, index|
- if !user_signed_in? && (@project.published? || @project.pending_attribution?)
- if @offers.size >= 3 && index == 3
= render 'offer_cta'
- contact_bloc = user_contact_bloc(offer.user, viewer: current_user, display_contact_info: offer.display_contact_info?)
.card.offer-card.mt-4[offer]{ class: offer_class(offer) }
.card-header.d-flex.justify-content-between.align-items-center.border-bottom-0
.offer-date
%span.text-muted
Offer filed on
= l(offer.created_at, format: '%d/%m/%Y à %Hh%M')
- if user_signed_in? && current_user.admin? && !offer.user.suspended_at.nil?
... exctera
Also, if I try this in my console, I don't have any problem...
Have you ever had this problem?
Don't hesitate to ask me if you need more information.
Aucun commentaire:
Enregistrer un commentaire