On Wednesday 29 April 2009 17.44:03 fffact wrote:
> hi all, i'm new to datamapper and i can't figure out how associations
> naming works.
> that sadly doesn't work. instead it yields this error:
>
> ArgumentError: +options[:links]+ entry nil not supported
>
> which i find not very informative.
>
> would you please provide some insight?
> thanks

require 'rubygems'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3::memory:')
class Author
  include DataMapper::Resource
  property :id, Serial
  property :name, String
  has n, :foobar,
    :through => Resource,
    :class_name => "Book",
    :child_key => [:book_id]
end

class Book
  include DataMapper::Resource
  property :id, Serial
  property :name, String
  has n, :authors,
    :through => Resource,
    :class_name => "Author",
    :child_key => [:author_id]
end

DataMapper::auto_migrate!

#that works fine, so that i can run this:

author = Author.create(:name => 'john')
book = Book.create(:name => 'cooffe')
book1 = Book.create(:name => 'milk')

author.foobar << book
author.foobar << book1

author.save
book.save
book1.save

author.foobar.each { |e| puts e.name }

Seems to work fine here...


--~--~---------~--~----~------------~-------~--~----~
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