Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

hide archived discussions from main view

  • Loading branch information...
commit 9bb7ebe7235112d6ab15556fdf97dc806cc030f9 1 parent 71930cf
Jia Brown authored
View
8 app/controllers/discussions_controller.rb
@@ -4,13 +4,13 @@ class DiscussionsController < ApplicationController
def index
@discussions = case params[:category]
when "conversation"
- @course.discussions.conversations
+ @course.discussions.active.conversations
when "review"
- @course.discussions.reviews
+ @course.discussions.active.reviews
when "evaluation"
- @course.discussions.evaluations
+ @course.discussions.active.evaluations
else
- @course.discussions.conversations
+ @course.discussions.active.conversations
end
end
View
8 app/models/discussion.rb
@@ -1,6 +1,14 @@
class Discussion < ActiveRecord::Base
belongs_to :course
+ def self.active
+ where(:archived => false)
+ end
+
+ def self.inactive
+ where(:archived => true)
+ end
+
def self.conversations
where(:category => "conversation")
end
View
5 db/migrate/20120317200349_add_archived_field_to_discussion.rb
@@ -0,0 +1,5 @@
+class AddArchivedFieldToDiscussion < ActiveRecord::Migration
+ def change
+ add_column :discussions, :archived, :boolean, :default => false
+ end
+end
View
7 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120316053737) do
+ActiveRecord::Schema.define(:version => 20120317200349) do
create_table "course_memberships", :force => true do |t|
t.integer "course_id"
@@ -33,8 +33,9 @@
t.text "subject"
t.text "body"
t.integer "course_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "archived", :default => false
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.