-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Quiz model class and association with MultipleChoiceQuestion class
- Loading branch information
Showing
9 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: quizzes | ||
# | ||
# id :integer not null, primary key | ||
# description :text | ||
# title :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Quiz < ApplicationRecord | ||
has_many :questions, | ||
class_name: 'MultipleChoiceQuestion', | ||
foreign_key: 'quiz_id', | ||
inverse_of: :quiz, | ||
dependent: :destroy | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateQuizzes < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :quizzes do |t| | ||
t.string :title | ||
t.text :description | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20181022152131_add_quiz_ref_to_multiple_choice_questions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddQuizRefToMultipleChoiceQuestions < ActiveRecord::Migration[5.2] | ||
def change | ||
add_reference :multiple_choice_questions, :quiz, foreign_key: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: quizzes | ||
# | ||
# id :integer not null, primary key | ||
# description :text | ||
# title :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
title: MyString | ||
description: MyText | ||
|
||
two: | ||
title: MyString | ||
description: MyText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: quizzes | ||
# | ||
# id :integer not null, primary key | ||
# description :text | ||
# title :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
require 'test_helper' | ||
|
||
class QuizTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |