Skip to content

Instantly share code, notes, and snippets.

@dmilith
Created December 22, 2008 01:54
Show Gist options
  • Select an option

  • Save dmilith/38831 to your computer and use it in GitHub Desktop.

Select an option

Save dmilith/38831 to your computer and use it in GitHub Desktop.
class Subdomain
include DataMapper::Resource
property :id, Serial, :index => true
property :user_id, Integer, :index => true
property :domain_id, Integer, :index => true
property :rack_app_id, Integer, :index => true
property :name, String
belongs_to :rack_app
belongs_to :user
belongs_to :domain
end
class UsagePermission
include DataMapper::Resource
property :id, Serial, :index => true
property :available_subdomains_count, Integer
property :domain_id, Integer, :index => true
property :user_id, Integer, :index => true
belongs_to :user
belongs_to :domain
end
class User
include DataMapper::Resource
has n, :usage_permissions
has n, :domains, :through => :usage_permissions, :mutable => true # workaround XXX http://datamapper.lighthouseapp.com/projects/20609/tickets/485-has-n-through-does-not-allow-saving-of-model
has n, :subdomains
has n, :ports
has n, :memory_usage_records
....
end
class Domain
include DataMapper::Resource
property :id, Serial, :index => true
property :name, String, :nullable => false, :default => "drakor.eu"
property :owner_id, Integer, :index => true
has n, :usage_permissions
has n, :users, :through => :usage_permissions, :mutable => true # workaround XXX http://datamapper.lighthouseapp.com/projects/20609/tickets/485-has-n-through-does-not-allow-saving-of-model
has n, :subdomains
belongs_to :owner, :class_name => "User"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment