Events: initial implementation
This commit is contained in:
@@ -20,21 +20,25 @@
|
||||
# team :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# event_id :integer
|
||||
# user_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_contests_on_slug (slug) UNIQUE
|
||||
# index_contests_on_user_id (user_id)
|
||||
# index_contests_on_event_id (event_id)
|
||||
# index_contests_on_slug (slug) UNIQUE
|
||||
# index_contests_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# user_id (user_id => users.id)
|
||||
# event_id (event_id => events.id)
|
||||
# user_id (user_id => users.id)
|
||||
#
|
||||
class Contest < ApplicationRecord
|
||||
extend FriendlyId
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :event, optional: true
|
||||
has_many :categories
|
||||
has_many :completions, dependent: :destroy
|
||||
has_many :contestants, dependent: :destroy
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
#
|
||||
# Table name: contestants
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# display_time :string
|
||||
# email :string
|
||||
# name :string
|
||||
# projected_time :string
|
||||
# qrcode :string
|
||||
# time_seconds :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
# id :integer not null, primary key
|
||||
# display_time :string
|
||||
# email :string
|
||||
# name :string
|
||||
# qrcode :string
|
||||
# time_seconds :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
||||
26
app/models/event.rb
Normal file
26
app/models/event.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: events
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# lang :string default("en")
|
||||
# name :string
|
||||
# shared_scoreboard :boolean
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_events_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# user_id (user_id => users.id)
|
||||
#
|
||||
class Event < ApplicationRecord
|
||||
belongs_to :user
|
||||
has_many :contests, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
end
|
||||
@@ -17,6 +17,7 @@
|
||||
# index_users_on_email_address (email_address) UNIQUE
|
||||
#
|
||||
class User < ApplicationRecord
|
||||
has_many :events, dependent: :destroy
|
||||
has_many :contests, dependent: :destroy
|
||||
has_many :sessions, dependent: :destroy
|
||||
has_secure_password
|
||||
|
||||
Reference in New Issue
Block a user