
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
-
Juanma Cervera March 23rd, 2010 @ 03:26 AM
I'm having the same problem in almost all the associations since a few days ago.
It is curious but I have the problem in a has-many association but not in a has-many-through that use the previous one.Juamq
-
Juanma Cervera March 25th, 2010 @ 07:17 AM
I'm having no problem now, after the last updates to the gems.
Juanma
-
Juanma Cervera March 25th, 2010 @ 07:18 AM
I'm having no problem now, after the last updates to the gems.
Juanma
-
Martin Gamsjaeger (snusnu) March 25th, 2010 @ 08:56 AM
- State changed from new to unconfirmed
- Assigned user set to Martin Gamsjaeger (snusnu)
- Milestone set to 1.0.0
Luca, can you also confirm that using latest datamapper/dm-core/master and datamapper/dm-more/master branches in your Gemfile fixes this issue?
-
LucaB March 25th, 2010 @ 01:09 PM
Hello,
I updated the libraries, and and I got the same problem.
I then started a new application from scratch, re-created the same models, and now I don't see any problem.
Thanks a lot!
LucaB -
Martin Gamsjaeger (snusnu) March 25th, 2010 @ 09:13 PM
- State changed from unconfirmed to resolved
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »