Given this code:
<<
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite # Create an in-memory database
DB.create_table(:locations) do
primary_key :id
String :name
end
DB.create_table(:copies) do
primary_key :id
Boolean :checked_out
foreign_key :location_id, :locations
end
class Location < Sequel::Model
one_to_many :copies
end
class Copy < Sequel::Model
many_to_one :locations
end
l = Location.create(:name => 'Here')
c = Copy.create(:checked_out => true)
l.add_copy(c)
puts "copy location = #{c.location.name}"
>>
Why do I get an "undefined method 'location' " in that last "puts"? I do
similar things in other code, so I must be missing something (again sigh
...).
Thanks,
--
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
-~----------~----~----~----~------~----~------~--~---