First of all, I've done lots of Ruby, but this is my first project with 
Sequel as my persistence layer.  Here is a sample of what is happening.  I 
start with the instantiation of the database and the models, and set up a 
simple association:

require 'sinatra'
require 'sinatra/sequel'

set :database, 'sqlite://foo.db'

migration "create initial schema" do
  database.drop_table?(:divesite)
  database.create_table :divesite do
    primary_key :id
    String :title, :size => 50
    String :description, :text => true
  end

  database.drop_table?(:dive)
  database.create_table :dive do
  primary_key :id
  Time :start
  Time :end
    foreign_key :divesite_id
    String  :description, :text => true
    Float :start_pressure
    Float :end_pressure
  end

end

class Dive < Sequel::Model(:dive)
  one_to_one :divesite
  set_allowed_columns :description

end
class Divesite < Sequel::Model(:divesite)
  one_to_many :dives
  set_allowed_columns :title, :description
end


Now if you do that, and then dump out the association reflection it does 
this (shortened for brevity):

{
                        :type => :one_to_many,
                        :name => :dives,
                        :class_name => "::Dife",
                        :class => nil,
                        :block => nil
}

Dife is not correct, and it means that the association is busted.  I've 
tried using "Dives" and changing the table to be plural, and I've tried 
setting the class_name at the association definition with a ", :class => 
'Dive'", but even with that it appears as though the add_* methods still 
become "add_dife".

I can't figure out what I'm doing wrong, or how to get the "auto-wiring" of 
the association to be correct per my schema and database structure.

Am I naming things wrong?  Not finding the settings needed to make this 
correct?

Any pointers would be gratefully accepted.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to