An appointment belongs to a schedule. Without using friendly_id, the following code works, as expected, to build a list of appointments:
def show
@appointments = Appointment.where(schedule_id: params[:id])
end
However, when I send the slug instead of the ID, things get more complicated. Something like Appointment.where(schedule.slug = "MYSLUG") is what I would love to do, but I ended up with this piece o' ugliness:
def show
@appointments = Appointment.where(schedule_id: Schedule.where(slug: params[:id]))
end
It works, but it seems like I'm making it too complicated.
Suggestions to improve this code gratefully accepted.