Kane, I did a post on many to many relationships that might help. Take a look here ...
http://steamcode.blogspot.com/2009/03/sequel-models-manytomany-manytomany.html On Fri, Apr 17, 2009 at 4:23 AM, Kane <[email protected]> wrote: > > Hello! > I have some problems with many_to_many associations… Post should has > comment and comments should has commets… > > class CreatePosts < Sequel::Migration > def up > create_table :posts do > primary_key :id > Varchar :author, :size => 128, :null => false > Text :data, :null => false > DateTime :created_at, :null => false > end > end > > def down > drop_table :posts > end > end > > class CreateComments < Sequel::Migration > def up > create_table :comments do > primary_key :id > DateTime :created_at, :null => false > Varchar :author, :size => 128, :null => false > Text :data, :null => false > foreign_key :post_id > end > end > def down > drop_table :comments > end > end > > #i think something wrong here, but don't know right way to do this > class CreateCommentsComments < Sequel::Migration > def up > create_table :comments_comments do > primary_key :id > foreign_key :comment_id, :comments > foreign_key :parent_id, :comments > end > end > def down > drop_table :comments_comments > end > end > > > class Post < Sequel::Model > one_to_many :comments > end > class Comment < Sequel::Model > many_to_one :post > many_to_many :comments > end > > > p.s. and sorry for my english, it's not my mother language > > > -- 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 -~----------~----~----~----~------~----~------~--~---
