Skip to content

Commit

Permalink
Resolve conflicts after pulled from original
Browse files Browse the repository at this point in the history
  • Loading branch information
wicz committed Mar 18, 2012
2 parents 5a2a0ca + 71930cf commit bffcdc8
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 5 deletions.
22 changes: 22 additions & 0 deletions app/controllers/discussions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class DiscussionsController < ApplicationController
before_filter :find_course

def index
@discussions = case params[:category]
when "conversation"
@course.discussions.conversations
when "review"
@course.discussions.reviews
when "evaluation"
@course.discussions.evaluations
else
@course.discussions.conversations
end
end

private

def find_course
@course = Course.find(params[:course_id])
end
end
3 changes: 2 additions & 1 deletion app/models/course.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Course < ActiveRecord::Base
has_many :course_memberships
has_many :discussions
has_many :course_memberships
has_many :tasks

def people
Expand Down
15 changes: 15 additions & 0 deletions app/models/discussion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Discussion < ActiveRecord::Base
belongs_to :course

def self.conversations
where(:category => "conversation")
end

def self.reviews
where(:category => "review")
end

def self.evaluations
where(:category => "evaluation")
end
end
11 changes: 11 additions & 0 deletions app/views/discussions/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
= link_to "Conversations", course_discussions_path(:category => "conversation")
|
= link_to "Reviews", course_discussions_path(:category => "review")
|
= link_to "Evaluations", course_discussions_path(:category => "evaluation")

%br
%br

- @discussions.each do |discussion|
%h3= discussion.subject
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
match '/auth/failure' => 'sessions#failure'
match '/logout' => 'sessions#destroy', as: 'logout'


resources :courses do
resources :tasks
resources :tasks, :discussions
end
resources :course_memberships
end
end
14 changes: 14 additions & 0 deletions db/migrate/20120316053737_create_discussions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateDiscussions < ActiveRecord::Migration
def change
create_table :discussions do |t|
t.string :category

t.text :subject
t.text :body

t.belongs_to :course

t.timestamps
end
end
end
11 changes: 9 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120316003602) do

create_table "course_memberships", :force => true do |t|
t.integer "course_id"
t.string "person_github_nickname"
Expand All @@ -35,4 +34,12 @@
t.datetime "updated_at", :null => false
end

end
create_table "discussions", :force => true do |t|
t.string "category"
t.text "subject"
t.text "body"
t.integer "course_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
30 changes: 30 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,34 @@

people.each do |person|
person.create(course_id: course.id, role: "Student") if person.empty?
end

conversations = [ "How awesome is Jordan Byron?",
"How many unicorns does it take to make a rainbow?",
"Can someone ask a serious question please?" ]

conversations.each do |e|
course.discussions.find_or_create_by_subject(
:subject => e, :category => "conversation"
)
end

evaluations = [ "My s10-e2 is ready for evaluation",
"Revisions have been made to my s10-e1",
"Come on, evaluate it, you know you want to!" ]

evaluations.each do |e|
course.discussions.find_or_create_by_subject(
:subject => e, :category => "evaluation"
)
end

reviews = ["Messy first spike on my individual project",
"Proof of concept patch to add archives to Newman",
"If you don't review this soon, I might go crazy!"]

reviews.each do |e|
course.discussions.find_or_create_by_subject(
:subject => e, :category => "review"
)
end

0 comments on commit bffcdc8

Please sign in to comment.