Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3359618
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:53:38+00:00 2026-05-18T02:53:38+00:00

Hi i have a table where i list different values. Now i want to

  • 0

Hi i have a table where i list different values. Now i want to add a total values to my table that counts the values from each column and adds it to a column with the total value. How do I do this? And is it possible to do this in a simple way in the view, or am I bound to do it in the model? Thanks for any help!

<div class="chart-data">
  <table>
    <caption>Data</caption>
    <thead>
      <tr>
        <% statistic.column_titles.each do |column| %>
          <th><%= column %></th>
        <% end %>
        <th>Total</th>
      </tr>
    </thead>
    <tbody>      
      <% statistic.rows.each do |row| %>
        <tr>
          <th scope="row"><%= row.title %></th>
          <% row.data.each do |column| %>
            <td><%= column %></td>
            <% end %>
        </tr>
          <------- Here i want to have the code that sums the values from the columns above to form the 'Total'
      <% end %>
    </tbody>
  </table>  
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:53:39+00:00Added an answer on May 18, 2026 at 2:53 am

    The simple solution would be to maintain a variable that sums up the column, then use it for the total at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with list of urls fetched from different sources. I want
We have a table value function that returns a list of people you may
I have a table with multiple rows in each row is a select list
I have a large table with list of scores like this, one score per
I have a table in my DB with a list of people. I need
I have a table a with a list of id's, and a user-defined function
I have a table which holds a list of criminal charges.These charges can be
I have a table which contains a list of products for a company. They
In SQL Server, I have a table where a column A stores some data.
Have/Want List Matching Algorithm I am implementing an item trading system on a high-traffic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.