app/views/events/_events.html.erb
<div class="row">
<% events.each do |event| %>
<div class="col-xl-4">
<div class="card event-card">
<% if event.event_image_valid? %>
<%= image_tag event.event_image.url, size: '200x180', class: 'card-img-top' %>
<% else %>
<%= image_tag 'https://res.cloudinary.com/agile-alliance-brazil/image/upload/v1623597789/img-empty_b8hdek.png', size: '200x180', class: 'card-img-top' %>
<% end %>
<div class="card-body">
<% if current_user&.organizer_of?(event) %>
<h5 class="card-title"><%= link_to event.name, event_attendances_path(event) %></h5>
<% else %>
<h5 class="card-title"><%= event.name %></h5>
<% end %>
<p class="card-text small"><%= l(event.start_date.to_date) %></p>
<p class="card-text small"><%= number_to_currency(event.registration_price_for(Attendance.new, :gateway)) %></p>
<% if current_user.present? && current_user.registrations_for_event(event).not_cancelled.present? %>
<%= link_to event_attendance_path(event, current_user.valid_attendance_for_event(event)), class: 'event-action-item' do %>
<i class="fa fa-eye"></i>
<%= I18n.t('attendandes.show.title') %>
<% end %>
<% else %>
<%= link_to new_event_attendance_path(event), class: 'event-action-item' do %>
<i class="fa fa-plus-square"></i>
<%= I18n.t('attendandes.new.title') %>
<% end %>
<% end %>
<% if current_user&.admin? %>
<%= link_to event_path(event), class: 'float-right' do %>
<i class="fas fa-cogs"></i>
<% end %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>