I have the following imagr. What this basically represents is a rota. What I am trying to do is implement this into a system that I am building using Ruby On Rails. However I have identified that my first thing to do is list the dates of the month vertically. Which I am somewhat a bit confused by. Horizontally the headers represents different hospitals. Against the days and hospitals are names which shows who is working at what hospital. The colour coding is not relevant now.
The horizontal headings are the hospital. These are a fixed value of 10 hospitals. What I am finding difficult is to generate the current day which in my image uses the current day as the 16th and goes up to the 12th of may.
I have attempted to come up with some pseudo code, but am not too sure if I am heading in the right direction with this
(Date.today..23.days.from_now).each do |d|; td= d.to_s(:short);
Though I was thinking that maybe encasing the inside the loop would automatically generate the cells for me alongside with the dates
Is there a possible solution to achieveing what I am trying to do.
My models are as followed:
- Department
- Hospital_booking
- Hospital
- role_user
- role
- rota_day
- user
Another thing that came to mind is that because I know that there is a fixed value of hospitals which is 10. I was thinking that maybe I could do something as followed:
<table class="rota">
<thead>
<th> Dates </th>
<th> Hospital </th>
<% end %>
</thead>
<% @Hospital.each do |Hospital| %>
<tr class="rota_days" id="rota_days<%= hospital_id %>">
This way it could loop through the hospitals and generate the headers however I will be still stuck in generating the dates
I think you are kind of on the right track, but am not 100% sure on where you are having issues.
To solve this I would pass the view
@hospitalsand@dayswhich correspond to which hospitals you want to list and which days you want to be listed. Theget_hospital_booking_for_daywould be a view helper you make that either returns the name of the person on duty or anbsp;so that the blank cells display correctly.Again, I’m not sure this is 100% correct for you but hopefully it will put you on the right track: