Hi,
I'm experiencing a very strange problem. I have two models Clip and
ClipCollection as follows:
class Clip
include DataMapper::Resource
property :collection_title, String, :nullable => false, :key =>
true
property :number, Integer, :nullable => false, :key =>
true
property :file, FilePath, :nullable => false
belongs_to :collection, :class_name =>
ClipCollection.to_s, :child_key => [:collection_title]
end
class ClipCollection
include DataMapper::Resource
property :title, String, :nullable => false, :key => true, :length
=> (0..250)
has n, :clips, :class_name => Clip.to_s, :child_key =>
[:collection_title]
end
In my controller I simply load all clip collections:
def index
@clip_collections = ClipCollection.all
display @clip_collections
end
and than iterate over them in the view:
%ul#clip_collections{ :title => 'Clips', :selected => 'true' }
- for clip_collection in @clip_collections
= partial :teaser, :clip_collection => clip_collection
- for clip_collection in @clip_collections
%ul{ :id => "clip_collection_#{clip_collection.title}", :title =>
'Clips', :selected => 'true' }
- for clip in @clip_collections.clips
= partial '/clips/teaser', :clip => clip
The problem is that line 5 in clip_collections/index.html.haml (%ul
{ :id => "clip_collection_#{clip_collection.title}", :title =>
'Clips', :selected => 'true' } ) raises:
undefined method `new_record?' for #<DataMapper::Collection:0x2769290>
Full Backtrace:
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
103:in `method_missing'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
638:in `method_missing'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property.rb:
450:in `lazy_load'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property.rb:
390:in `get'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property_set.rb:
82:in `get'
/Library/Ruby/Gems/1.8/gems/merb-haml-1.0/lib/merb-haml/template.rb:
52:in `map'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property_set.rb:
55:in `each'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property_set.rb:
55:in `each'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property_set.rb:
82:in `map'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/property_set.rb:
82:in `get'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/
relationship.rb:178:in `attach_parent'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/
many_to_one.rb:55:in `replace'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/
many_to_one.rb:21:in `collection='
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
537:in `relate_resource'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
252:in `push'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
252:in `each'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
252:in `push'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
529:in `add'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/collection.rb:
23:in `load'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/
data_objects_adapter.rb:51:in `read_many'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/
data_objects_adapter.rb:171:in `with_connection'
/Library/Ruby/Gems/1.8/gems/dm-core-0.9.6/lib/dm-core/adapters/
data_objects_adapter.rb:40:in `read_many'
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
89:in `[]'
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
89:in `lazy_load'
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
13:in `each'
/Users/marcoow/Documents/Projekte/ipron.mobi/app/views/
clip_collections/index.html.haml:5:in
`__Users__marcoow__Documents__Projekte__ipron_mobi__app__views__clip__collections__index_html_haml'
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
14:in `each'
/Library/Ruby/Gems/1.8/gems/extlib-0.9.8/lib/extlib/lazy_array.rb:
14:in `each'
/Users/marcoow/Documents/Projekte/ipron.mobi/app/views/
clip_collections/index.html.haml:3:in
`__Users__marcoow__Documents__Projekte__ipron_mobi__app__views__clip__collections__index_html_haml'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/controller/
mixins/render.rb:133:in `send'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/controller/
mixins/render.rb:133:in `render'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/controller/
mixins/render.rb:218:in `display'
/Users/marcoow/Documents/Projekte/ipron.mobi/app/controllers/
clip_collections.rb:6:in `index'
/Library/Ruby/Gems/1.8/gems/merb-action-args-1.0/lib/merb-action-args/
abstract_controller.rb:40:in `__send__'
/Library/Ruby/Gems/1.8/gems/merb-action-args-1.0/lib/merb-action-args/
abstract_controller.rb:40:in `_call_action'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/controller/
abstract_controller.rb:285:in `_dispatch'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/controller/
merb_controller.rb:191:in `_dispatch'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/dispatch/
dispatcher.rb:102:in `dispatch_action'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/dispatch/
dispatcher.rb:74:in `handle'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/dispatch/
dispatcher.rb:36:in `handle'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/rack/
application.rb:17:in `call'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/rack/
middleware/static.rb:28:in `call'
/Library/Ruby/Gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:63:in
`pre_process'
/Library/Ruby/Gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:54:in
`process'
/Library/Ruby/Gems/1.8/gems/thin-1.0.0/lib/thin/connection.rb:39:in
`receive_data'
/Library/Ruby/Gems/1.8/gems/eventmachine-0.12.2/lib/eventmachine.rb:
231:in `run_machine'
/Library/Ruby/Gems/1.8/gems/eventmachine-0.12.2/lib/eventmachine.rb:
231:in `run'
/Library/Ruby/Gems/1.8/gems/thin-1.0.0/lib/thin/backends/base.rb:57:in
`start'
/Library/Ruby/Gems/1.8/gems/thin-1.0.0/lib/thin/server.rb:150:in
`start'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/rack/adapter/
thin.rb:29:in `start_server'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/rack/adapter/
abstract.rb:235:in `start_at_port'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/rack/adapter/
abstract.rb:85:in `start'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/server.rb:
174:in `bootup'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core/server.rb:
42:in `start'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/lib/merb-core.rb:169:in
`start'
/Library/Ruby/Gems/1.8/gems/merb-core-1.0/bin/merb:11
/usr/bin/merb:19:in `load'
/usr/bin/merb:19
Is that a bug or have I got something wrong?
Thanks for help on this,
Marco
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" 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/merb?hl=en
-~----------~----~----~----~------~----~------~--~---