diff --git a/app/models/question.rb b/app/models/question.rb index 5a45af6..1eb5eee 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -4,6 +4,7 @@ class Question < ActiveRecord::Base has_many :tags, as: :subscriber has_many :answers belongs_to :user + validates :title, presence: true validates :content, presence: true include Modify diff --git a/app/serializers/question_serializer.rb b/app/serializers/question_serializer.rb index 43d8eb8..84f4bff 100644 --- a/app/serializers/question_serializer.rb +++ b/app/serializers/question_serializer.rb @@ -1,5 +1,5 @@ class QuestionSerializer < ActiveModel::Serializer - attributes :id, :title, :content, :votes, :comments, :tags, :answers, + attributes :id, :user_id, :title, :content, :votes, :comments, :tags, :answers, :created_at, :updated_at has_many :comments, as: :comment_on diff --git a/db/schema.rb b/db/schema.rb index b411eb8..0f6aaf0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,12 @@ # # It's strongly recommended that you check this file into your version control system. - ActiveRecord::Schema.define(version: 20160201170223) do create_table "answers", force: :cascade do |t| t.integer "user_id" t.integer "question_id" t.string "content" - t.integer "votes" t.datetime "created_at", null: false t.datetime "updated_at", null: false end @@ -26,7 +24,6 @@ create_table "comments", force: :cascade do |t| t.integer "user_id" t.string "content" - t.integer "votes" t.integer "comment_on_id" t.string "comment_on_type" t.datetime "created_at", null: false @@ -39,7 +36,6 @@ t.integer "user_id" t.string "title" t.string "content" - t.integer "votes" t.datetime "created_at", null: false t.datetime "updated_at", null: false end @@ -103,4 +99,5 @@ add_index "votes", ["user_id"], name: "index_votes_on_user_id" add_index "votes", ["voteable_type", "voteable_id"], name: "index_votes_on_voteable_type_and_voteable_id" + end diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e8..785559b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,23 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) + +questions_list =[ + ["Requirements for Amity", "What are the requirements for geting accommodation at Amity" ,2], + ["Renewing Amity Contract", "What happens at the expiration of the 6 months Amity resident agreement? Is it automatically renewed or are there processes to follow to get it renew. In same vein what steps are required if someone wants to leave before the expiration of the agreement.", 1 ], + ["What is simulations all about?", "What is simulations all about?", 2 ], + ["Leaving Amity before end of Contract", "What happenes if I want to leave Amity before the the time my agreement expires? Will the dues still be deducted from my salary? ", 1 ], + ["Coding classes during month one?", "Why dont we have coding classes during month one?", 2 ], + ["Simulations", "Is there a fixed time period for completing simulations? If yes what is it? If no, why were some fellows dropped for 'been slow' in completing their simulation's checkpoint project?", 1], + ["Going on leave", "How do I request for leave when I am not yet eligible to go on leave and when I am?", 2 ], + ["Dropping a fellow.", "What actions or inactions might cause a fellow to be dropped from simulations?", 1 ], + ["Must we do simulations and checkpoints at the same time?", "We've got simulations project, we've got checkpoints; any particular reason why it's necessary that we undertake the two concurrently?", 2 ], + ["Does Billable hours count outside work hours?", "For instance, if I organize a weekly catch up session for fellows who are not very comfortable with their stack, on a saturday or sunday, would it be consodered as billable hours?", 1], + ["Duties of the Amity Reps?", "What are the duties of the Amity Reps?", 2 ], + ["Why is month one just for a month?", "Why is month one just for a month? Can't it be a part and parcel of simulations as a whole?", 1 ], + ["What is the whole purpose of simulations project?", "What is the whole purpose of simulations project when the checkpoints do a better job of enabling fellows to learn things faster?", 2 ] +] + +questions_list.each do |title, content, user_id| + Question.create(title: title, content: content, user_id: user_id) +end