#1220 ✓resolved
LucaB

undefined method `metaclass'

Reported by LucaB | March 20th, 2010 @ 09:10 AM | in 1.0.0

This problem occurs on a trial application created with the templates taken at dm-rails on github.
Database is postgres, ruby is ruby enterprise.

When I try to access to related objects, I get the following error:

NoMethodError: undefined method metaclass' for Contract:Class

It happens both with integer and string keys, and on both sides of the relationships.

Below there is a basic example to help me to better explain.

May be I'm doing some mistake? Thanks a lot.

class Contract

include DataMapper::Resource

property :id, Serial

property :title, String property :description, Text property :signing, Date

belongs_to :customer

end

class Customer

include DataMapper::Resource

property :id, Serial

property :name, String property :info, Text property :first_contact, Date

has n, :contracts

end

ctr = Contract.first +----+----------------+-------------+---------+-------------+ | id | title | description | signing | customer_id | +----+----------------+-------------+---------+-------------+ | 1 | first contract | no commenct | | 1 | +----+----------------+-------------+---------+-------------+ 1 row in set

me = Customer.first +----+------+------------+---------------+ | id | name | info | first_contact | +----+------+------------+---------------+ | 1 | Luca | no comment | | +----+------+------------+---------------+ 1 row in set

me.contracts NoMethodError: undefined method metaclass' for Customer:Class<br/>

from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/relationship.rb:369:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/property.rb:240:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:718:in `model_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:732:in `ancestor_instance_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:730:in `each'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:730:in `ancestor_instance_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:718:in `model_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:614:in `model_method_defined?'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/collection.rb:1437:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/associations/one_to_many.rb:94:in `lazy_load'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/associations/one_to_many.rb:57:in `get'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/relationship.rb:338:in `contracts'
from (irb):5

ctr.customer NoMethodError: undefined method metaclass' for Contract:Class<br/>

from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/relationship.rb:369:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/property.rb:240:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:718:in `model_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:732:in `ancestor_instance_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:730:in `each'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:730:in `ancestor_instance_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:718:in `model_methods'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model.rb:614:in `model_method_defined?'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/collection.rb:1437:in `method_missing'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/associations/many_to_one.rb:178:in `lazy_load'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/associations/many_to_one.rb:115:in `get'
from /home/******/.bundle/ruby/1.8/bundler/gems/dm-core-0e854cef5afba8b1adcb503d951adf578cbb190e-active_support/lib/dm-core/model/relationship.rb:338:in `customer'
from (irb):7

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages