rupert wrote:
Here's a full script that demonstrates the problem. An object retrieved via an association is somehow different than one retrieved directly. --------------------------------- #!/usr/bin/ruby require 'rubygems' require 'dm-core' DataMapper::Logger.new(STDOUT, :debug) adapter = DataMapper.setup(:default, "sqlite3::memory:") class PlayItem include DataMapper::Resource property :id, Integer, :key => true property :event_id, Integer property :name, Text belongs_to :event end class Event include DataMapper::Resource property :id, Integer, :key => true property :type, Discriminator property :name, Text has n, :play_items end class EventOne < Event end class EventTwo < Event end def find_class(event) case event when EventOne puts 'One' when EventTwo puts 'Two' else puts "Unknown event type #{event}" end end DataMapper.auto_migrate! e = EventOne.create(:id => 1, :name => 'E1') p = e.play_items.build(:id => 1, :name => 'Test') e.save e2 = Event.first p2 = PlayItem.first puts e, e2, p.event, p, p2, e.play_items[0] find_class e # This works. find_class e2 # So does this. find_class p.event # This doesn't. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~--- |
- [DataMapper] Using an associated model as a case statement s... Earle Clubb
- [DataMapper] Re: Using an associated model as a case st... Caius Durling
- [DataMapper] Re: Using an associated model as a case st... rupert
- [DataMapper] Re: Using an associated model as a cas... Earle Clubb
- [DataMapper] Re: Using an associated model as a... rupert
- [DataMapper] Re: Using an associated model ... Earle Clubb
