I'm having a similar problem. Shown here: 
https://gist.github.com/835a015d52c86cfb2770

Pretty sure it's because DM is looking for the 'ord' property in the
model defined in :class_name (in this case the PlayItem model) instead
of the model in the :through attribute (PlayChain)



On Nov 3, 11:12 am, Earle Clubb <[EMAIL PROTECTED]> wrote:
> I'm having trouble ordering a "has n, :through" association.  I need the code 
> at the end of this post to return a collection ordered by the 'ord' field in 
> the 'play_chains' table when I do this:puts 
> PlayItem.first.chained_events.inspect
> Instead I receive the following stack 
> trace:/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/query.rb:309:in 
> `normalize_order': Unknown property 'ord' (ArgumentError)
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/query.rb:287:in `map'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/query.rb:287:in 
> `normalize_order'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/query.rb:181:in 
> `initialize'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/model.rb:394:in `new'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/model.rb:394:in 
> `scoped_query'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/model.rb:252:in `all'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/relationship_chain.rb:26:in
>  `send'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/relationship_chain.rb:26:in
>  `get_children'
>          ... 7 levels...
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/relationship_chain.rb:25:in
>  `get_children'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/one_to_many.rb:251:in
>  `children'
>         from 
> /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/one_to_many.rb:309:in
>  `method_missing'
>         from ../dm-test.rb:57What am I doing wrong? Here is the code:
> class Event
>   include DataMapper::Resource
>   property :id,   Integer, :key => true
>   property :name, Text,    :lazy => false, :unique_index => true
>   has n, :play_chains
>   # FIXME: Ordering this association doesn't work.
>   has n, :chained_play_items, :through => :play_chains,
>          :class_name => 'PlayItem', :order => [:ord]
> end
> class PlayItem
>   include DataMapper::Resource
>   property :id,       Integer, :key => true
>   property :name,     Text,    :lazy => false, :unique_index => true
>   property :event_id, Integer, :nullable => false
>   belongs_to :event
>   has n,     :play_chains  # FIXME: Ordering this association doesn't work.  
> has n, :chained_events, :through => :play_chains,
>          :class_name => 'Event', :order => [:ord]
> end
> class PlayChain
>   include DataMapper::Resource
>   property :id,           Integer, :key => true
>   property :play_item_id, Integer, :nullable => false
>   property :event_id,     Integer, :nullable => false
>   property :ord,          Integer, :nullable => false
>   belongs_to :chained_event,     :class_name => 'Event'
>   belongs_to :chained_play_item, :class_name => 'PlayItem'
> end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to