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

  • Home
  • SEARCH
  • 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 6591401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:25:07+00:00 2026-05-25T17:25:07+00:00

I am trying to implement a highchart that sums hours for a specified week.

  • 0

I am trying to implement a highchart that sums hours for a specified week. What it is currently doing is looking at my ‘efforts’ table and summing all records in that table. However I am trying to sum hours for a particular week, for the current user. I have the following snippet from my highcharts.html.erb.

 series: [{
                name: 'Hours',
           data: [<% @efforts.each do |effort| %>
[Date.UTC(<%= effort.week_commencing.strftime("%Y,%m-1,%d") %>),<%= Effort.sum(:hours).                                                                                          
where(:week_commencing => week_commencing, :user_id => current_user.id)%>],<% end %>]

        }]
    });
});

I have the full code available on pastebin http://pastebin.com/ifbQfR0i

Is there a way around this?

Updated: Error message

NameError in Statistics#range

Showing /home/Project/app/views/statistics/range.html.erb where line

115 raised:

undefined local variable or method `week_commencing’ for #<#:0x9fdadc8> Extracted source (around line #115):

             name: 'Hours',
     data: [<% @efforts.each do |effort| %>
             [Date.UTC(<%= effort.week_commencing.strftime("%Y,%m-1,%d")

%>),<%= Effort.sum(:hours).
where(:week_commencing =>
week_commencing, :user_id => current_user.id)%>],<% end %>]
}] }); });

Efforts.rb

== Schema Information

 Table name: efforts

  id              :integer(4)      not null, primary key
  project_task_id :integer(4)
  user_id         :integer(4)
  week_commencing :date
  hours           :float
  created_at      :datetime
  updated_at      :datetime
  • 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-25T17:25:07+00:00Added an answer on May 25, 2026 at 5:25 pm

    I’m not quite sure, but shouldn’t it be:

    %>),<%= Effort.sum(:hours). where(:week_commencing => effort.week_commencing, :user_id => current_user.id)%>],<% end %>] }] }); });
    

    instead of

    %>),<%= Effort.sum(:hours). where(:week_commencing => week_commencing, :user_id => current_user.id)%>],<% end %>] }] }); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All I am currently trying implement something along the lines of dim l_stuff as
I am currently trying implement a QThread that contains a socket connection. The socket
trying to implement a dialog-box style behaviour using a separate div section with all
when trying to implement an Aspect, that is responsible for catching and logging a
Trying to implement some nested loops that are spitting out good old nested html
SetFocus I'm trying implement the above Se Focus code in a Class Library that
Im trying to implement a save feature to save an html file. Currently it
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
When trying to implement a simple OpenGL application, I was surprised that while it
Im trying to implement pagination using multiple searching criteria. Supposed I Have student table.

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.