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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:10:27+00:00 2026-05-31T23:10:27+00:00

We have the following model: payment.rb: class Payment < ActiveRecord::Base has_many :currencies default_scope :include

  • 0

We have the following model:

payment.rb:

class Payment < ActiveRecord::Base
  has_many :currencies

  default_scope :include => :currencies
end

We are using default_scope to eager load the currencies. When we run this we get the following error:

[2012-03-22 21:43:25] ERROR NoMethodError: undefined method `each' for nil:NilClass
/home/me/.rvm/gems/jruby-1.6.7@my_project/gems/activerecord-3.2.1/lib/active_record/associations/preloader/association.rb:88:in `associated_records_by_owner'
org/jruby/RubyArray.java:1615:in `each'
/home/me/.rvm/gems/jruby-1.6.7@my_project/gems/activerecord-3.2.1/lib/active_record/associations/preloader/association.rb:85:in `associated_records_by_owner'
...

The problem can be found in:

Line 88 and 89 in association.rb (github link):

...
owner_key = record[association_key_name].to_s

owners_map[owner_key].each do |owner|
...

When I step through the code I can see that record[association_key_name] is a BigDecimal e.g. 108.0, and when to_s is applied it becomes “108.0”. However, the keys in the owners_map hash is expecting “108” not “108.0”

The association_key_name is the name of the foreign key in the Oracle database and is defined as type Number. The primary key is also defined as type Number, but strangely enough it doesn’t resolve to a BigDecimal.

Any ideas? Is this a possible bug? Or does the precision on the database column need altered?

System Info:
JRuby on Rails (3.2.1)
ActiveRecord JDBC Adapter
Oracle Database (using views instead of tables)

  • 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-31T23:10:28+00:00Added an answer on May 31, 2026 at 11:10 pm

    The problem stems from the fact that the foreign key on the database was defined as Number with precision. Thanks to tharrison for pointing me to this article.

    I got our DBA to remove the precision on the field and everything worked fine. Of course, we are in the fortunate position of building a new product where our schema can be easily changed…

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

Sidebar

Related Questions

I have following model: class Customer < ActiveRecord::Base has_one :cart end class Cart <
I have a following model class Order < ActiveRecord::Base has_many :products, :through => :line_items
i have following model setup class Category < ActiveRecord::Base has_ancestry :cache_depth => true, :depth_cache_column
I have the following model and methods: class UserPrice < ActiveRecord::Base attr_accessible :price, :purchase_date,
I have the following model, Purchase, on my Rails app: class Purchase < ActiveRecord::Base
I have the following model associations: class Slider < ActiveRecord::Base has_one :featured_happening, :as =>
I have following User model, embeds the Category model, class User include Mongoid::Document include
I have the following model in datamapper: class Student include DataMapper::Resource property :id, Serial
I have a following model with mongoid rails3 class Address include Mongoid::Document embedded_in :person,
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage

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.