Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

60 lines (43 sloc) 0.971 kb
DB = Sequel.sqlite
Sequel::Model.plugin :schema
Sequel::Model.plugin :polymorphic
class Asset < Sequel::Model
set_schema do
primary_key :id
String :name
Integer :attachable_id
String :attachable_type
end
many_to_one :attachable, :polymorphic => true
end
class Tagging < Sequel::Model
set_schema do
Integer :taggable_id
String :taggable_type
Integer :tag_id
end
many_to_one :taggable, :polymorphic => true
many_to_one :tag
end
class Post < Sequel::Model
set_schema do
primary_key :id
String :name
end
one_to_many :assets, :as => :attachable
many_to_many :tags, :through => :taggings, :as => :taggable
end
class Note < Sequel::Model
set_schema do
primary_key :id
String :name
end
one_to_many :assets, :as => :attachable
end
class Tag < Sequel::Model
set_schema do
primary_key :id
String :name
end
end
[Asset, Post, Note, Tag, Tagging].each {|klass| klass.create_table!}
Jump to Line
Something went wrong with that request. Please try again.