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 1018979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:56:23+00:00 2026-05-16T10:56:23+00:00

I have a simple problem regarding a loop in a Rails controller. Here’s the

  • 0

I have a simple problem regarding a loop in a Rails controller.

Here’s the original sample code, the purpose of which is to specify the data to be used in an open flash chart (pie chart).

#controller
data_1 = [
  OFC2::PieValue.new(:value => 20,  :label => 'GroupA', :font_size => 15),
  OFC2::PieValue.new(:value => 30, :label =>  'GroupB', :font_size => 15)
]

I need to do this:

data_1 = [
  @groups.each do |group|
    OFC2::PieValue.new(:value => group.value,  :label => group.name, :font_size => 15),
  end
]

Two questions:

  1. The comma at the end of that line poses a problem. The last entry cannot have a comma.
  2. Even when I try to get this simple loop working by temporarily bypassing the comma (such as adding another record after the end without a comma), I am getting errors:

    unexpected ‘,’, expecting kEND (for OFC2 line)
    unexpected ‘]’, expecting kEND (last line of above code)
    unexpected kEND, expecting ‘]’ (end of controller)

This is bugging me because it should be a simple loop. What’s going on?

  • 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-16T10:56:23+00:00Added an answer on May 16, 2026 at 10:56 am

    Maybe try going a different route.

    data_1 = Array.new
    
    @groups.each do |g|
      data_1 << OFC2::PieValue.new(:value => g.value,  :label => g.name, :font_size => 15)
    end
    

    Does this make sense?

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

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I realized I was using a very very large version… May 16, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer My personal preference is simplexml_load_string since it makes handeling XML… May 16, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer A tangential answer: Perhaps you need to try an alternative… May 16, 2026 at 11:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm doing a simple program regarding methods. But I have one problem. Everything is
I have defined a for loop as follows which scans through a file made
Good day code knights, I have a tricky problem that I cannot see a
Posted: Mon Nov 30, 2009 5:08 pm Post subject: Simple Problem With Intent Extras
I've set up a simple, single-service server which has been working just fine with
Android 2.1 update 1 Eclipse 3.5 I have a problem reading data from my
Real World Problem: I have my app hosted on Heroku , who (to my
I'm dealing with a design problem that I'm sure has a simple answer and/or
I have this very huge XML file of size 2.8GB. This is Polish Wikipedia's
I am struggling with a sensible logic loop for stripping out nodes from an

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.