Set up association and models
This commit is contained in:
parent
a1ce39643b
commit
c9ae859bcf
5 changed files with 32 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ class Booth < ApplicationRecord
|
|||
attr_accessor :invite_responsible
|
||||
|
||||
belongs_to :conference
|
||||
belongs_to :booth_type
|
||||
has_many :booth_requests, dependent: :destroy
|
||||
has_many :users, through: :booth_requests
|
||||
|
||||
|
|
|
|||
17
app/models/booth_type.rb
Normal file
17
app/models/booth_type.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BoothType < ApplicationRecord
|
||||
belongs_to :program, touch: true
|
||||
has_many :booths, dependent: :restrict_with_error
|
||||
|
||||
has_paper_trail meta: { conference_id: :conference_id },
|
||||
ignore: %i[updated_at]
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
private
|
||||
|
||||
def conference_id
|
||||
program.conference_id
|
||||
end
|
||||
end
|
||||
|
|
@ -52,6 +52,7 @@ class Conference < ApplicationRecord
|
|||
through: :program,
|
||||
source: :events
|
||||
has_many :event_types, through: :program
|
||||
has_many :booth_types, through: :program
|
||||
|
||||
has_many :surveys, as: :surveyable, dependent: :destroy do
|
||||
def for_registration
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class Program < ApplicationRecord
|
|||
|
||||
has_many :cfps, dependent: :destroy
|
||||
has_many :event_types, dependent: :destroy
|
||||
has_many :booth_types, dependent: :destroy
|
||||
has_many :tracks, dependent: :destroy
|
||||
has_many :difficulty_levels, dependent: :destroy
|
||||
has_many :schedules, dependent: :destroy
|
||||
|
|
|
|||
13
db/schema.rb
13
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_06_03_143107) do
|
||||
ActiveRecord::Schema.define(version: 2019_08_17_094930) do
|
||||
|
||||
create_table "answers", force: :cascade do |t|
|
||||
t.string "title"
|
||||
|
|
@ -28,6 +28,15 @@ ActiveRecord::Schema.define(version: 2019_06_03_143107) do
|
|||
t.index ["user_id"], name: "index_booth_requests_on_user_id"
|
||||
end
|
||||
|
||||
create_table "booth_types", force: :cascade do |t|
|
||||
t.integer "program_id"
|
||||
t.string "title", null: false
|
||||
t.string "description"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["program_id"], name: "index_booth_types_on_program_id"
|
||||
end
|
||||
|
||||
create_table "booths", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
|
|
@ -39,6 +48,8 @@ ActiveRecord::Schema.define(version: 2019_06_03_143107) do
|
|||
t.integer "conference_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "booth_type_id"
|
||||
t.index ["booth_type_id"], name: "index_booths_on_booth_type_id"
|
||||
end
|
||||
|
||||
create_table "cfps", force: :cascade do |t|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue