Ruby on rails Ruby rails季度循环

Ruby on rails Ruby rails季度循环,ruby-on-rails,Ruby On Rails,我有一个银行应用程序,其中显示一个对账单表。目前,下表代码中有一列表示年份,旁边有一列表示每月,旁边有一列表示每个银行账户。我希望更改它,使其显示每年四个季度。我该怎么做呢 %table %thead %tr %th.year(rowspan=2) Year %th.accounts{colspan: @customer.accounts.size} Accounts %tr - fetch_cu_accounts(@customer.id

我有一个银行应用程序,其中显示一个对账单表。目前,下表代码中有一列表示年份,旁边有一列表示每月,旁边有一列表示每个银行账户。我希望更改它,使其显示每年四个季度。我该怎么做呢

%table
  %thead
    %tr
      %th.year(rowspan=2) Year
      %th.accounts{colspan: @customer.accounts.size} Accounts
    %tr
      - fetch_cu_accounts(@customer.id).each do |account|
        %th= account.name
  - @today.year.downto(@today.year - 3) do |year|
    %tbody
      - x = (@today.year == year) ? @today.month : 12
      - x.downto(1) do |month|
        %tr
          - if month == x
            %td{rowspan: x}= year
          %td
          - fetch_cu_accounts(@customer.id).each do |account|
            %td
              - stmt = account.statement(year, month)
              = link_to 'View', url(:statements, :show, id: stmt.to_s)
              = link_to image_tag('/icons/document-pdf.png', alt: 'Download PDF'), url(:statements, :show, id: stmt, format: :pdf), class: :pdf

四分之一而不是几个月?@David Aldridge是的,求你了!quarter=((@today.month-1)/3)+1您在哪一方面有问题?计算当前季度是什么,生成季度列表?