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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:54:29+00:00 2026-05-11T17:54:29+00:00

Can anyone tell me what’s wrong with this code? class Dataset < ActiveRecord::Base has_many

  • 0

Can anyone tell me what’s wrong with this code?

class Dataset < ActiveRecord::Base
  has_many  :dataitems  

def self.get_hash(dataset_id) 
  @dataitems = Dataset.find_by_id(24).dataitems
  @dataitems.each do |di|
    dataset_hash[di.axis0value] = di.axis1value #assign value for each category value
  end
  return dataset_hash
end

When run in dev environment it gives the following error in development.log:

rocessing BleeController#refresh_my_graph (for
127.0.0.1 at 2009-05-07 21:58:54) [GET]   Session ID: 8179153011071621ae181e852b03fbe1   Parameters: {"dataset_id"=>"24", "action"=>"refresh_my_graph", "controller"=>"blee"}   [4;36;1mDataset Columns (0.005285)[0m   [0;1mSHOW FIELDS FROM datasets[0m   [4;35;1mDataset Load (0.001132)[0m   [0mSELECT * FROM datasets WHERE (datasets.`id` = 24) LIMIT 1[0m   [4;36;1mDataitem Load (0.000646)[0m   [0;1mSELECT * FROM dataitems WHERE (dataitems.dataset_id = 24) [0m


NameError (undefined local variable or method `dataset_hash' for Dataset:Class):
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1235:in `method_missing'
    /app/models/dataset.rb:12:in `get_hash'

The funny thing is, it works exactly as it should when run through the console. Any help greatly appreciated.

  • 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-11T17:54:29+00:00Added an answer on May 11, 2026 at 5:54 pm

    Looks like you need to define the dataset_hash in your method. Something like this:

    def self.get_hash(dataset_id)
      dataset_hash = {}
      @dataitems = Dataset.find_by_id(24).dataitems
      @dataitems.each do |di|
        dataset_hash[di.axis0value] = di.axis1value #assign value for each category value
      end
      return dataset_hash
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 155k
  • Answers 155k
  • 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 jhat -baseline indeed won't work with dumps produced by jmap.… May 12, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Give a look to the Vim Visual Mode. The Shift+Ctrl+LeftArrowKey… May 12, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer As long as you do not write any specific queries… May 12, 2026 at 10:43 am

Related Questions

Can anyone tell me what is the memory usage overhead associated with PHP opcode
Can anyone tell me what exactly does this Java code do? SecureRandom random =
Can anyone tell me what version of the .NET framework (CLR and BCL) is
Can anyone tell me what the need/advantage is to using a web service with
Can anyone tell me what this cast has for effect (besides setting happyNumber to

Trending Tags

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

Top Members

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.