I have an admin page on my site that usually lists all appointments that users have scheduled when I use @appointments.each. I'm trying to figure out how I can list all appointments with the date attribute after whatever day it currently is, and how I would list all appointments with dates before the current date. I've looked at a bunch of stackoverflow examples but anytime I change the query, none of the appointments show up anymore (like the one directly below). Heres my admin page:
<div align="center">
<div class="col-md-6">
<div class="card">
<h5 class="card-header">All Currently Scheduled Appointments</h5>
<div class="card-body">
<%@appointments.where("date >= ?", Date.current) do | appt |%>
<%="Appointment for #{appt.owner_email} on #{appt.date} in the #{appt.time}"%> <%= link_to 'Edit', edit_appointment_path(appt) %>
</br>
<%end%>
</div>
</div>
</div>
</div>
Heres my appointment table in the schema file, the date attribute stores them as "2019-03-21" for example.
create_table "appointments", force: :cascade do |t|
t.string "VIN"
t.string "owner_email"
t.string "date"
t.string "time"
t.string "reason"
t.string "parts_needed"
t.string "hours_needed"
t.string "cost"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Aucun commentaire:
Enregistrer un commentaire