I'm trying to use one to one associations where two tables can have one to
one associations with another table. Here's a simple example of what I'm
trying to do ...
<<
require 'rubygems'
require 'sequel'
# Create an in-memory database
DB = Sequel.sqlite
DB.create_table :businesses do
primary_key :id
String :name, :text=>true, :unique=>true
end
DB.create_table :people do
primary_key :id
String :name, :text=>true, :unique=>true
end
DB.create_table :addresses do
primary_key :id
String :address
end
class Business < Sequel::Model
one_to_one :address
end
# Create the Employee model.
class Person < Sequel::Model
one_to_one :address
end
class Address < Sequel::Model
one_to_one :business
one_to_one :person
end
business = Business.create(:name => "The Business")
person = Person.create(:name => "Bob")
address_1 = Address.create(:address => "123 W. Lane, Anytown, CA 91110")
address_2 = Address.create(:address => "124 W. Lane, Anytown, CA 91110")
business.add_address(address_1)
person.add_address(address_2)
>>
When I try to add the addresses I get ...
<<
onetotest.rb:43:in `<main>': undefined method `add_address' for #<Business
@values={:id=>1, :name=>"The Business"}> (NoMethodError)
>>
The documentation seems to imply that this should work.
Thoughts?
--
Scott
http://steamcode.blogspot.com/
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" 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/sequel-talk?hl=en.