Skip to content

Commit

Permalink
Merge pull request #19 from andela-iamadi/ft-new-questions-resources
Browse files Browse the repository at this point in the history
Ft new questions resources
  • Loading branch information
innocentamadi committed Feb 3, 2016
2 parents 4fc74de + b9272fc commit 771e303
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/question_serializer.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@
#
# 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

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
Expand All @@ -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
Expand Down Expand Up @@ -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
20 changes: 20 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 771e303

Please sign in to comment.