Dear all
I have the following data in a table and I want to create a
2-dimensional table to display it.
Table: services
col01 col02 col03
AH AS 1
AH CS 2
AH MS 3
BH BS 1
BH CS 1
BH MS 1
CH IS 1
CH BS 2
CH MS 1
DH CS 1
DH MS 1
I want to have this present on web
AS BS CS IS MS
AH 1 2 3
BH 1 1 1
CH 2 1 1
DH 1 1
I only have the idea to display the column and row title. Can anyone
give me some idea how to generate this dynamically?. Thanks
controllers/dashboard_controller.rb
def main
@hospital_code = Service.find_by_sql(“select distinct hospital_code
from services”)
@service_code = Service.find_by_sql(“select distinct service_code
from services”)
end
views/dashboard/main.html.erb
<% for s in @service_code %> | <%=s.col02 %> | <% end %>
---|---|
<%=h.col01 %> |
Many thanks
Valentino