Create 'poll_question_answers' table
This commit is contained in:
@@ -15,6 +15,7 @@ class Poll::Question < ActiveRecord::Base
|
|||||||
|
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
has_many :answers
|
has_many :answers
|
||||||
|
has_many :question_answers, class_name: 'Poll::QuestionAnswer', foreign_key: 'poll_question_id'
|
||||||
has_many :partial_results
|
has_many :partial_results
|
||||||
belongs_to :proposal
|
belongs_to :proposal
|
||||||
|
|
||||||
|
|||||||
5
app/models/poll/question_answer.rb
Normal file
5
app/models/poll/question_answer.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Poll::QuestionAnswer < ActiveRecord::Base
|
||||||
|
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'poll_question_id'
|
||||||
|
|
||||||
|
validates :title, presence: true
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class CreatePollQuestionAnswers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :poll_question_answers do |t|
|
||||||
|
t.string :title
|
||||||
|
t.text :description
|
||||||
|
t.references :poll_question, index: true, foreign_key: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
11
db/schema.rb
11
db/schema.rb
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171002191347) do
|
ActiveRecord::Schema.define(version: 20171004025903) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -669,6 +669,14 @@ ActiveRecord::Schema.define(version: 20171002191347) do
|
|||||||
add_index "poll_partial_results", ["origin"], name: "index_poll_partial_results_on_origin", using: :btree
|
add_index "poll_partial_results", ["origin"], name: "index_poll_partial_results_on_origin", using: :btree
|
||||||
add_index "poll_partial_results", ["question_id"], name: "index_poll_partial_results_on_question_id", using: :btree
|
add_index "poll_partial_results", ["question_id"], name: "index_poll_partial_results_on_question_id", using: :btree
|
||||||
|
|
||||||
|
create_table "poll_question_answers", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.text "description"
|
||||||
|
t.integer "poll_question_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "poll_question_answers", ["poll_question_id"], name: "index_poll_question_answers_on_poll_question_id", using: :btree
|
||||||
|
|
||||||
create_table "poll_questions", force: :cascade do |t|
|
create_table "poll_questions", force: :cascade do |t|
|
||||||
t.integer "proposal_id"
|
t.integer "proposal_id"
|
||||||
t.integer "poll_id"
|
t.integer "poll_id"
|
||||||
@@ -1143,6 +1151,7 @@ ActiveRecord::Schema.define(version: 20171002191347) do
|
|||||||
add_foreign_key "poll_partial_results", "poll_officer_assignments", column: "officer_assignment_id"
|
add_foreign_key "poll_partial_results", "poll_officer_assignments", column: "officer_assignment_id"
|
||||||
add_foreign_key "poll_partial_results", "poll_questions", column: "question_id"
|
add_foreign_key "poll_partial_results", "poll_questions", column: "question_id"
|
||||||
add_foreign_key "poll_partial_results", "users", column: "author_id"
|
add_foreign_key "poll_partial_results", "users", column: "author_id"
|
||||||
|
add_foreign_key "poll_question_answers", "poll_questions"
|
||||||
add_foreign_key "poll_questions", "polls"
|
add_foreign_key "poll_questions", "polls"
|
||||||
add_foreign_key "poll_questions", "proposals"
|
add_foreign_key "poll_questions", "proposals"
|
||||||
add_foreign_key "poll_questions", "users", column: "author_id"
|
add_foreign_key "poll_questions", "users", column: "author_id"
|
||||||
|
|||||||
Reference in New Issue
Block a user