Skip to content

Instantly share code, notes, and snippets.

@paav-o
Created June 13, 2012 20:18
Show Gist options
  • Select an option

  • Save paav-o/2926262 to your computer and use it in GitHub Desktop.

Select an option

Save paav-o/2926262 to your computer and use it in GitHub Desktop.
Nakkikoneen datamalliluonnos
# app/models/event.rb
class Event < ActiveRecord::Base
field :name, :type => String # "Maailmanlopun reivit"
field :date, :type => Date # "2012-12-21"
field :description, :type => String # "Osallistumalla nakkiin pääset maksutta bileisiin..."
has_many :tasks
end
# app/models/task.rb
class Task < ActiveRecord::Base
field :name, :type => String # "Lipunmyynti"
field :description, :type => String # "Tässä nakissa myydään lippuja."
field :available_hours, :type => Array # [22, 23, 00, 01, 02, 03]
belongs_to :event
has_many :reservations, :dependent => true
has_many :volunteers, :through => :reservations
end
# app/models/reservation.rb
class Reservation < ActiveRecord::Base
field :hour, :type => Integer # 23
belongs_to :task
belongs_to :volunteer
end
# app/models/volunteer.rb
class Volunteer < ActiveRecord::Base
field :name, :type => String # "Erkki Esimerkki"
field :email, :type => String # "erkki.esimerkki@aalto.fi"
field :phone, :type => String # "0401234567"
field :will_construct, :type => Boolean
field :will_deconstruct, :type => Boolean
has_many :reservations, :dependent => true
has_many :tasks, :through => :reservations
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment